subtree-push nightly-2026-08-11 - #7026
Conversation
…om outer attributes It's possible that at least one of the attributes is a custom proc macro that takes the module tokens as an input. It's hard to know for sure since rustfmt only operates on the AST pre-expansion. In this case we'll be overly permissive and just ignore the file not found error so rustfmt can still try formatting the input. Fixes rustfmt issue 6959
rustfmt fix: allow file not found errors for external mods annotated with `#[my_macro]` Tracking issue: rust-lang/rust#54727 `#[my_macro]` was stabilized for macro hygiene 2.0 in rust-lang/rust#157857. There isn't a guarantee that the external module exists on the file system so ignore any file not found errors encountered when trying to resolve the module's file. Fixes rust-lang#6959 r? @petrochenkov cc: @TimNN
…imi,jieyouxu rustfmt: Discover modules via `cfg_select!` This PR renames all occurrences of `cfg_match!` in rustfmt to `cfg_select!`. This makes the module file detection logic from rust-lang#6522 kick in for `cfg_select!` instead of `cfg_match!`, which no longer exists. This PR performs no other adjustments to the logic to be as small as possible. I am opening this PR in this repo since that is also the target for the more comprehensive rust-lang/rust#154202, which covers more than merely detecting other files through `cfg_select!`. Closes rust-lang/rust#158371. CC: @ytmimi, @CAD97
`cfg_select!` parsing needs to be implemented in rustfmt right now because there's no good way to call `rustc_attr_parsing::parse_cfg_select`.
The plan is to leverage `rewrite_match_body` to help with `cfg_select!` formatting.
Apply feedback from PR review.
Per the PR review I'm making `context: &RewriteContext<'_>` the first argument. Also moved the `shape` and `span` to follow the `context`.
Because `inside_macro` is a `Rc<Cell<bool>>` cloning the entire context doesn't actually isolate the `inside_macro` state. However, I've added a `debug_assert!` to make sure that we only ever call `context.leave_macro` when we're on a code path that immediately returns from `rewrite_macro_inner` so that we don't unexpectedly impact default macro handling where we need to be more cautious about adding or removing tokens.
Bumping the toolchain version as part of a git subtree push. Before: ``` 1.99.0-nightly (9f36de775 2026-07-19) ``` After: ``` 1.99.0-nightly (12c36e253 2026-08-10) ```
|
After reviewing the diffs I'm pretty confident that all formatting changes are due to |
|
Some Diffs that I found odd or the formatting surprised me. rust-lang/rust/library/unwind/src/types.rsNot sure why rustfmt prefers that the expression be placed on the next line. 2026-08-11T05:01:30.098954Z ERROR check_diff: Diff found in 'rust' when formatting rust/library/unwind/src/types.rs
--- original
+++ modified
@@ -21,28 +21,29 @@
pub type _Unwind_Exception_Class = u64;
pub type _Unwind_Word = *const u8;
-pub const unwinder_private_data_size: usize = cfg_select! {
- target_arch = "x86" => 5,
- all(target_arch = "x86_64", not(any(target_os = "windows", target_os = "cygwin"))) => 2,
- all(target_arch = "x86_64", any(target_os = "windows", target_os = "cygwin")) => 6,
- all(target_arch = "arm", not(target_vendor = "apple")) => 20,
- all(target_arch = "arm", target_vendor = "apple") => 5,
- all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")) => 2,
- all(target_arch = "aarch64", target_pointer_width = "64", target_os = "windows") => 6,
- all(target_arch = "aarch64", target_pointer_width = "32") => 5,
- target_arch = "m68k" => 2,
- any(target_arch = "mips", target_arch = "mips32r6") => 2,
- target_arch = "csky" => 2,
- any(target_arch = "mips64", target_arch = "mips64r6") => 2,
- any(target_arch = "powerpc", target_arch = "powerpc64") => 2,
- target_arch = "s390x" => 2,
- any(target_arch = "sparc", target_arch = "sparc64") => 2,
- any(target_arch = "riscv64", target_arch = "riscv32") => 2,
- all(target_family = "wasm", target_os = "emscripten") => 20,
- target_family = "wasm" => 2,
- target_arch = "hexagon" => 5,
- any(target_arch = "loongarch32", target_arch = "loongarch64") => 2,
-};
+pub const unwinder_private_data_size: usize =
+ cfg_select! {
+ target_arch = "x86" => 5,
+ all(target_arch = "x86_64", not(any(target_os = "windows", target_os = "cygwin"))) => 2,
+ all(target_arch = "x86_64", any(target_os = "windows", target_os = "cygwin")) => 6,
+ all(target_arch = "arm", not(target_vendor = "apple")) => 20,
+ all(target_arch = "arm", target_vendor = "apple") => 5,
+ all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")) => 2,
+ all(target_arch = "aarch64", target_pointer_width = "64", target_os = "windows") => 6,
+ all(target_arch = "aarch64", target_pointer_width = "32") => 5,
+ target_arch = "m68k" => 2,
+ any(target_arch = "mips", target_arch = "mips32r6") => 2,
+ target_arch = "csky" => 2,
+ any(target_arch = "mips64", target_arch = "mips64r6") => 2,
+ any(target_arch = "powerpc", target_arch = "powerpc64") => 2,
+ target_arch = "s390x" => 2,
+ any(target_arch = "sparc", target_arch = "sparc64") => 2,
+ any(target_arch = "riscv64", target_arch = "riscv32") => 2,
+ all(target_family = "wasm", target_os = "emscripten") => 20,
+ target_family = "wasm" => 2,
+ target_arch = "hexagon" => 5,
+ any(target_arch = "loongarch32", target_arch = "loongarch64") => 2,
+ };rust-lang/rust/library/std/tests/sync/rwlock.rsThe code was probably a little more readable when the arms were written with blocks, but maybe someone would argue that that this is better. 2026-08-11T05:01:30.101593Z ERROR check_diff: Diff found in 'rust' when formatting rust/library/std/tests/sync/rwlock.rs
--- original
+++ modified
@@ -907,42 +907,35 @@
let mut read_lock_ctr: u32 = 0;
let rwlock: RwLock<i32> = RwLock::new(0);
- const MAX_READERS: u32 = cfg_select! {
- miri => 100,
- any(
- all(target_os = "windows", not(target_vendor = "win7")),
- target_os = "linux",
- target_os = "android",
- target_os = "freebsd",
- target_os = "openbsd",
- target_os = "dragonfly",
- target_os = "fuchsia",
- all(target_family = "wasm", target_feature = "atomics"),
- target_os = "hermit",
- target_os = "motor",
- ) => {
- (1 << 30) - 2
- },
- any(
- target_family = "unix",
- all(target_os = "windows", target_vendor = "win7", target_pointer_width = "64"),
- all(target_vendor = "fortanix", target_env = "sgx"),
- target_os = "xous",
- target_os = "teeos",
- ) => {
- u32::MAX
- },
- // Otherwise a form of deadlock is observed.
- all(target_os = "windows", target_vendor = "win7", target_pointer_width = "32") => {
- (1 << 28) - 1
- },
- target_os = "solid_asp3" => {
- (1 << 30)
- },
- _ => {
- u32::MAX
- }
- };
+ const MAX_READERS: u32 =
+ cfg_select! {
+ miri => 100,
+ any(
+ all(target_os = "windows", not(target_vendor = "win7")),
+ target_os = "linux",
+ target_os = "android",
+ target_os = "freebsd",
+ target_os = "openbsd",
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ all(target_family = "wasm", target_feature = "atomics"),
+ target_os = "hermit",
+ target_os = "motor",
+ ) => (1 << 30) - 2,
+ any(
+ target_family = "unix",
+ all(target_os = "windows", target_vendor = "win7", target_pointer_width = "64"),
+ all(target_vendor = "fortanix", target_env = "sgx"),
+ target_os = "xous",
+ target_os = "teeos",
+ ) => u32::MAX,
+ // Otherwise a form of deadlock is observed.
+ all(target_os = "windows", target_vendor = "win7", target_pointer_width = "32") => {
+ (1 << 28) - 1
+ }
+ target_os = "solid_asp3" => (1 << 30),
+ _ => u32::MAX,
+ };rust-lang/rust/library/std/src/sys/pipe/unix.rsWhen the 2026-08-11T05:01:30.104592Z ERROR check_diff: Diff found in 'rust' when formatting rust/library/std/src/sys/pipe/unix.rs
--- original
+++ modified
@@ -25,22 +25,18 @@
target_os = "openbsd",
target_os = "cygwin",
target_os = "redox"
- ) => {
- unsafe {
- cvt(libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC))?;
- Ok((Pipe::from_raw_fd(fds[0]), Pipe::from_raw_fd(fds[1])))
- }
- }
- _ => {
- unsafe {
- cvt(libc::pipe(fds.as_mut_ptr()))?;
+ ) => unsafe {
+ cvt(libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC))?;
+ Ok((Pipe::from_raw_fd(fds[0]), Pipe::from_raw_fd(fds[1])))
+ },
+ _ => unsafe {
+ cvt(libc::pipe(fds.as_mut_ptr()))?;
- let fd0 = Pipe::from_raw_fd(fds[0]);
- let fd1 = Pipe::from_raw_fd(fds[1]);
- fd0.set_cloexec()?;
- fd1.set_cloexec()?;
- Ok((fd0, fd1))
- }
- }
+ let fd0 = Pipe::from_raw_fd(fds[0]);
+ let fd1 = Pipe::from_raw_fd(fds[1]);
+ fd0.set_cloexec()?;
+ fd1.set_cloexec()?;
+ Ok((fd0, fd1))
+ },
}
} |
Hm, I almost wonder that if the formatting rule there should be something like "if newlines or vertical alignment was done for the arm cfg clauses, use |
All good. It was a fairly easy subtree push. A few merge conflicts, but nothing crazy. If we need to redo it that should be okay. Also, now that we have the merge queue and we're using a merge commit strategy I wonder if it makes a difference. When we merge, a new merge commit will just get added on top of everything else. Also, rust bot should would have commented if the merge caused conflicts for this PR, right? |
It might be acceptable, but ideally we settle on the formatting soon because once this lands on stable it will be harder to change outside of a style edition / config addition. I think it would be best to have @rust-lang/style take a look at this and potentially write some formal rules in the Style Guide. |
My understanding is that since #7004 doesn't cause merge conflicts for this subtree-push direction we should be okay without having to redo this PR, because we should pick up #7004 in the subtree-pull direction (we'd add a relnotes + version bump PR after this PR merges anyway).
Yes, and also the github UI will show it can't be merged (granted github UI's merge conflict indicator uses a very conservative default conflict resolution strategy IINM) |
Bumping the toolchain version as part of a git subtree push.
Before:
After: