style: change rustfmt edition to 2024

This commit adds `style_edition = "2024"` as a rustfmt config setting.
All other changes are automatically generated by `cargo fmt`.

The 2024 style edition fixes several bugs and changes some defaults.
https://doc.rust-lang.org/edition-guide/rust-2024/rustfmt-style-edition.html

Most of the changes made to our code result from a different sorting
method for `use` statements, improved ability to split long lines, and
contraction of short trailing expressions into single-line expressions.

While our MSRV is still 1.70, we use more recent toolchains for
development, so we can already benefit from the improvements of the new
style edition. Formatting is not require for building fish, so builds
with Rust 1.70 are not affected by this change.

More context can be found at
https://github.com/fish-shell/fish-shell/issues/11630#issuecomment-3406937077

Closes #11959
This commit is contained in:
Daniel Rainer
2025-10-16 17:33:06 +02:00
committed by Johannes Altmanninger
parent 1c3a6a463d
commit 43f8d7478e
122 changed files with 508 additions and 500 deletions

View File

@@ -3,8 +3,8 @@
mod tests;
use super::locale::Locale;
use super::printf_impl::{pad, ConversionSpec, Error, ModifierFlags};
use decimal::{Decimal, DigitLimit, DIGIT_WIDTH};
use super::printf_impl::{ConversionSpec, Error, ModifierFlags, pad};
use decimal::{DIGIT_WIDTH, Decimal, DigitLimit};
use std::cmp::min;
use std::fmt::Write;

View File

@@ -4,9 +4,9 @@
mod fmt_fp;
mod printf_impl;
pub use printf_impl::{sprintf_locale, Error, FormatString};
pub use printf_impl::{Error, FormatString, sprintf_locale};
pub mod locale;
pub use locale::{Locale, C_LOCALE, EN_US_LOCALE};
pub use locale::{C_LOCALE, EN_US_LOCALE, Locale};
#[cfg(test)]
mod tests;

View File

@@ -66,11 +66,7 @@ fn next_group_size(&self, digits_left: usize) -> usize {
// Divide remaining digits by repeat_group.
// Apply any remainder to the first group.
let res = (digits_left - accum) % (repeat_group as usize);
if res > 0 {
res
} else {
repeat_group as usize
}
if res > 0 { res } else { repeat_group as usize }
}
}

View File

@@ -1,6 +1,6 @@
use crate::arg::ToArg;
use crate::locale::{Locale, C_LOCALE, EN_US_LOCALE};
use crate::{sprintf_locale, Error, FormatString};
use crate::locale::{C_LOCALE, EN_US_LOCALE, Locale};
use crate::{Error, FormatString, sprintf_locale};
use libc::c_char;
use std::f64::consts::{E, PI, TAU};
use std::fmt;