style: keep only stable options in rustfmt.toml
Continuous integration / Check (push) Successful in 1m37s
Continuous integration / Test Suite (push) Failing after 2s
Continuous integration / Rustfmt (push) Successful in 26s
Continuous integration / Clippy (push) Successful in 1m35s

The fmt job runs on stable, and stable rustfmt does not fail on a
nightly-only option: it prints "unstable features are only available in
nightly channel" and carries on with its own defaults. Carrying ten of
them in the config is what let the tree drift from what the job expects.

This corrects the previous commit, which claimed all ten were ignored.
Nine are. `version = "Two"` is not: despite the warning saying it cannot
be set, on stable it still drives import order and collapses short
if/else onto one line. Dropping it reformats 18 files back to the
default style, which is the bulk of this diff.

Dropped anyway, so the repository's style stops depending on behavior
the tool itself says it does not support and could stop honoring in any
release. The file now records that, so the options do not come back
without the fmt job moving to nightly along with them.

Verified: cargo fmt --all -- --check exits 0 with no warnings and no
diffs, 138 unit tests pass, clippy --all-targets -- -D warnings stays at
zero.
This commit is contained in:
Alexandre Possebom
2026-07-28 14:24:03 -03:00
parent e45efeeecf
commit fe491cc8d6
19 changed files with 76 additions and 71 deletions
+12 -11
View File
@@ -1,15 +1,16 @@
# So opcao estavel aqui, de proposito. O CI roda `cargo fmt --all -- --check` em
# stable, e no stable a opcao de nightly nao falha: o rustfmt avisa "unstable
# features are only available in nightly channel" e segue em frente. Este arquivo
# pedia dez delas, entao a arvore formatada em nightly nunca batia com o que o
# job esperava, e ele vivia vermelho.
#
# Cuidado com o `version = "Two"`: o aviso diz que nao da para setar, mas ele
# MUDA a saida no stable (ordem dos imports e if/else curto numa linha). Foi
# removido assim mesmo, para o estilo do repositorio nao depender de um
# comportamento que a propria ferramenta diz nao suportar e que pode sumir numa
# versao qualquer. Se alguma dessas opcoes voltar, o job de fmt do CI tem que ir
# para nightly junto, senao a divergencia volta com ela.
max_width = 160
newline_style = "Unix"
use_field_init_shorthand = true
use_try_shorthand = true
unstable_features = true
version = "Two"
comment_width = 100
error_on_line_overflow = true
format_code_in_doc_comments = true
format_macro_bodies = true
format_macro_matchers = true
format_strings = true
# imports_granularity = "Module"
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
+5 -1
View File
@@ -116,7 +116,11 @@ impl Claims {
}
fn ensure(allowed: bool) -> Result<(), AppError> {
if allowed { Ok(()) } else { Err(AppError::Unauthorized) }
if allowed {
Ok(())
} else {
Err(AppError::Unauthorized)
}
}
#[cfg(test)]
+5 -5
View File
@@ -1,19 +1,19 @@
use std::sync::Arc;
use axum::{
Json,
extract::{Path, State},
Json,
};
use serde_json::{Value, json};
use serde_json::{json, Value};
use crate::{
AppState,
controllers::availability::{company_local_date, compute_slots},
error::AppError,
models::{
appointment::{NewAppointment, UpdateAppointment},
professional::Claims,
},
AppState,
};
pub async fn create_appointment(claims: Claims, State(app): State<Arc<AppState>>, Json(appointment): Json<NewAppointment>) -> Result<Json<Value>, AppError> {
@@ -224,7 +224,6 @@ mod tests {
use super::*;
use crate::{
AppState,
config::Config,
error::DataAccessError,
mailer::{DynMailer, MockMailer},
@@ -238,7 +237,8 @@ mod tests {
service::{DynServiceRepository, MockServiceRepository},
},
routes,
tests::utils::{RequestBuilderExt, generate_professional, response_json},
tests::utils::{generate_professional, response_json, RequestBuilderExt},
AppState,
};
/// Um horario sempre no futuro. Os handlers rejeitam `start` no passado, entao
+6 -6
View File
@@ -1,15 +1,15 @@
use std::sync::Arc;
use axum::{Json, extract::State};
use jsonwebtoken::{Validation, decode};
use serde_json::{Value, json};
use axum::{extract::State, Json};
use jsonwebtoken::{decode, Validation};
use serde_json::{json, Value};
use crate::{
AppState, KEYS,
error::AppError,
models,
models::professional::{Claims, Login},
utils::verify_password,
AppState, KEYS,
};
pub async fn login(State(app): State<Arc<AppState>>, Json(credentials): Json<Login>) -> Result<Json<Value>, AppError> {
@@ -73,7 +73,6 @@ mod tests {
use super::*;
use crate::{
AppState,
config::Config,
error::DataAccessError,
mailer::{DynMailer, MockMailer},
@@ -86,7 +85,8 @@ mod tests {
service::{DynServiceRepository, MockServiceRepository},
},
routes,
tests::utils::{RequestBuilderExt, generate_professional, response_json},
tests::utils::{generate_professional, response_json, RequestBuilderExt},
AppState,
};
#[tokio::test]
+6 -6
View File
@@ -1,22 +1,22 @@
use std::sync::Arc;
use axum::{
Json,
extract::{Path, State},
Json,
};
use chrono::{Datelike, Duration, NaiveDate};
use chrono_tz::Tz;
use serde_json::{Value, json};
use serde_json::{json, Value};
use crate::{
AppState,
availability::{Busy, SlotQuery, Window, available_slots},
availability::{available_slots, Busy, SlotQuery, Window},
error::AppError,
models::{
professional::Claims,
time_off::NewTimeOff,
working_hours::{NewWorkingHours, WeekSchedule},
},
AppState,
};
pub async fn get_working_hours(claims: Claims, State(app): State<Arc<AppState>>, Path(id): Path<i32>) -> Result<Json<Value>, AppError> {
@@ -251,7 +251,6 @@ mod tests {
use super::*;
use crate::{
AppState,
config::Config,
mailer::{DynMailer, MockMailer},
models::time_off::TimeOff,
@@ -264,7 +263,8 @@ mod tests {
service::{DynServiceRepository, MockServiceRepository},
},
routes,
tests::utils::{RequestBuilderExt, generate_professional, response_json},
tests::utils::{generate_professional, response_json, RequestBuilderExt},
AppState,
};
/// A folga 1 pertence ao profissional 7. `owner_company` decide de que empresa
+5 -5
View File
@@ -1,18 +1,18 @@
use std::sync::Arc;
use axum::{
Json,
extract::{Path, State},
Json,
};
use serde_json::{Value, json};
use serde_json::{json, Value};
use crate::{
AppState,
error::AppError,
models::{
client::{Client, UpdateClient},
professional::Claims,
},
AppState,
};
pub async fn update(
@@ -111,7 +111,6 @@ mod tests {
use super::*;
use crate::{
AppState,
config::Config,
error::DataAccessError,
mailer::{DynMailer, MockMailer},
@@ -125,7 +124,8 @@ mod tests {
service::{DynServiceRepository, MockServiceRepository},
},
routes,
tests::utils::{RequestBuilderExt, generate_professional, response_json},
tests::utils::{generate_professional, response_json, RequestBuilderExt},
AppState,
};
#[tokio::test]
+6 -6
View File
@@ -1,18 +1,18 @@
use std::sync::Arc;
use axum::{
Json,
extract::{Path, State},
Json,
};
use serde_json::{Value, json};
use serde_json::{json, Value};
use crate::{
AppState,
error::AppError,
models::{
company::{Company, UpdateCompany, validate_slug},
company::{validate_slug, Company, UpdateCompany},
professional::Claims,
},
AppState,
};
pub async fn get_company_by_id(claims: Claims, State(app): State<Arc<AppState>>, Path(id): Path<i32>) -> Result<Json<Value>, AppError> {
@@ -87,7 +87,6 @@ mod tests {
use super::*;
use crate::{
AppState,
config::Config,
mailer::{DynMailer, MockMailer},
models::company::Company,
@@ -100,7 +99,8 @@ mod tests {
service::{DynServiceRepository, MockServiceRepository},
},
routes,
tests::utils::{RequestBuilderExt, generate_professional, response_json},
tests::utils::{generate_professional, response_json, RequestBuilderExt},
AppState,
};
#[tokio::test]
+5 -5
View File
@@ -1,17 +1,17 @@
use std::sync::Arc;
use axum::{
Json,
extract::{Path, State},
Json,
};
use serde_json::{Value, json};
use serde_json::{json, Value};
use crate::{
AppState,
authz::Role,
error::AppError,
models::professional::{Claims, Professional, UpdateProfessional},
utils::hash_password,
AppState,
};
pub async fn get_all(claims: Claims, State(app): State<Arc<AppState>>) -> Result<Json<Value>, AppError> {
@@ -184,7 +184,6 @@ mod tests {
use super::*;
use crate::{
AppState,
config::Config,
error::DataAccessError,
mailer::{DynMailer, MockMailer},
@@ -197,7 +196,8 @@ mod tests {
service::{DynServiceRepository, MockServiceRepository},
},
routes,
tests::utils::{RequestBuilderExt, generate_professional, generate_professional_with_company, response_json},
tests::utils::{generate_professional, generate_professional_with_company, response_json, RequestBuilderExt},
AppState,
};
#[tokio::test]
+3 -3
View File
@@ -8,19 +8,19 @@
use std::sync::Arc;
use axum::{
Json,
extract::{Path, State},
Json,
};
use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use serde_json::{json, Value};
use crate::{
AppState,
controllers::availability::{company_local_date, compute_slots},
error::AppError,
magic_link,
models::{appointment::NewAppointment, client::Client, company::Company, professional::Professional, service::Service},
AppState,
};
#[derive(Serialize)]
+3 -3
View File
@@ -1,18 +1,18 @@
use std::sync::Arc;
use axum::{
Json,
extract::{Path, State},
Json,
};
use serde_json::{Value, json};
use serde_json::{json, Value};
use crate::{
AppState,
error::AppError,
models::{
professional::Claims,
service::{NewService, ProfessionalServices, UpdateService},
},
AppState,
};
pub async fn create(claims: Claims, State(app): State<Arc<AppState>>, Json(service): Json<NewService>) -> Result<Json<Value>, AppError> {
+4 -4
View File
@@ -1,16 +1,16 @@
use std::{fs::File, io::Write, path::PathBuf, sync::Arc};
use axum::{
Json,
extract::{Multipart, Path, State},
Json,
};
use image::{ImageFormat, imageops::FilterType};
use serde_json::{Value, json};
use image::{imageops::FilterType, ImageFormat};
use serde_json::{json, Value};
use crate::{
AppState,
error::AppError,
models::professional::{Claims, UpdateProfessional},
AppState,
};
pub async fn upload(claims: Claims, State(app): State<Arc<AppState>>, Path(id): Path<i32>, mut multipart: Multipart) -> Result<Json<Value>, AppError> {
let professional = match app.professional_repo.get_professional_by_id(id).await {
+1 -1
View File
@@ -1,4 +1,4 @@
use axum::{Json, extract::multipart::MultipartError, http::StatusCode, response::IntoResponse};
use axum::{extract::multipart::MultipartError, http::StatusCode, response::IntoResponse, Json};
use serde_json::json;
#[derive(Debug)]
+1 -1
View File
@@ -8,7 +8,7 @@
//!
//! A claim `purpose` e a segunda barreira, checada aqui e em nenhum outro lugar.
use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation, decode, encode};
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
+1 -1
View File
@@ -10,7 +10,7 @@
use std::sync::Arc;
use async_trait::async_trait;
use lettre::{AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor, message::header::ContentType, transport::smtp::authentication::Credentials};
use lettre::{message::header::ContentType, transport::smtp::authentication::Credentials, AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor};
#[cfg(test)]
use mockall::automock;
+2 -2
View File
@@ -2,17 +2,17 @@ use std::sync::Arc;
use autometrics::{autometrics, prometheus_exporter::encode_to_string};
use axum::{
Router,
body::Body,
http::{Request, StatusCode},
middleware::{self, Next},
response::Response,
routing::{delete, get, patch, post, put},
Router,
};
use mailer::{DynMailer, SmtpMailer};
use once_cell::sync::Lazy;
use sqlx::postgres::PgPoolOptions;
use tower_governor::{GovernorLayer, governor::GovernorConfigBuilder};
use tower_governor::{governor::GovernorConfigBuilder, GovernorLayer};
use tower_http::{
cors::{Any, CorsLayer},
trace,
+3 -3
View File
@@ -1,10 +1,10 @@
use axum::Json;
use chrono::{DateTime, Utc};
use jsonwebtoken::{DecodingKey, EncodingKey, Header, encode};
use jsonwebtoken::{encode, DecodingKey, EncodingKey, Header};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use serde_json::{json, Value};
use crate::{KEYS, error::AppError, utils::get_timestamp_from_now};
use crate::{error::AppError, utils::get_timestamp_from_now, KEYS};
#[derive(Clone, Deserialize, Serialize, sqlx::FromRow)]
pub struct Professional {
+1 -1
View File
@@ -11,7 +11,7 @@
use std::{sync::Arc, time::Duration};
use crate::{AppState, magic_link, notify};
use crate::{magic_link, notify, AppState};
const SWEEP_INTERVAL: Duration = Duration::from_secs(300);
+2 -2
View File
@@ -1,8 +1,8 @@
use axum::{
Json,
body::Body,
http::{Request, header::CONTENT_TYPE, request},
http::{header::CONTENT_TYPE, request, Request},
response::Response,
Json,
};
use http_body_util::BodyExt;
use serde_json::Value;
+5 -5
View File
@@ -4,17 +4,17 @@ use std::{
};
use axum::{
RequestPartsExt,
extract::{FromRef, FromRequestParts},
http::request::Parts,
RequestPartsExt,
};
use axum_extra::{
headers::{authorization::Bearer, Authorization},
TypedHeader,
headers::{Authorization, authorization::Bearer},
};
use jsonwebtoken::{Validation, decode};
use jsonwebtoken::{decode, Validation};
use crate::{AppState, KEYS, error::AppError, models::professional::Claims};
use crate::{error::AppError, models::professional::Claims, AppState, KEYS};
pub fn get_timestamp_from_now(hours: u8) -> u64 {
let hours = 3600 * hours as u64;
@@ -56,8 +56,8 @@ where
}
use argon2::{
password_hash::{rand_core::OsRng, PasswordHash, PasswordHasher, PasswordVerifier, SaltString},
Argon2,
password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString, rand_core::OsRng},
};
pub fn hash_password(password: &str) -> Result<String, AppError> {