Repro
This is a code rustfmt formatted.
fn main() {
#[cfg(target_os = "linux")]
let x = 42
else {
todo!()
};
// #[cfg(target_os = "linux")]
let x = 42 else { todo!() };
}
With some attribute on a let-else statement, rustfmt always inserts newline before else. When removing the attribute, this doesn't happen and rustfmt works as intended.
Expected behavior
My expectation is that rustfmt does not change formatting looking at the existence of attribute:
fn main() {
#[cfg(target_os = "linux")]
let x = 42 else { todo!() };
// #[cfg(target_os = "linux")]
let x = 42 else { todo!() };
}
Environment
- rustfmt: 1.6.0-stable (5680fa18 2023-08-23)
- Installed via rustup's stable toolchain
- Rust: 1.72.0
- OS: Windows 10