You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project builds before cargo fmt but fails to build after:
fmt-bracket-bug (master) $ cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
fmt-bracket-bug (master) $ cargo fmt
fmt-bracket-bug (master) $ cargo build
Compiling fmt-bracket-bug v0.1.0 (/Users/avh/research/fmt-bracket-bug)
error: this file contains an unclosed delimiter
--> src/lib.rs:19:3
|
1 | pub const fn vector_width() -> usize {
| - unclosed delimiter
2 | #[cfg(feature = "vec_width_2")]
3 | {
| - unclosed delimiter
4 | { 2
| - this delimiter might not be properly closed...
5 | }
| - ...as it matches this but it has different indentation
...
19 | }
| ^
error[E0308]: mismatched types
--> src/lib.rs:1:32
|
1 | pub const fn vector_width() -> usize {
| ------------ ^^^^^ expected `usize`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.
error: could not compile `fmt-bracket-bug`
To learn more, run the command again with --verbose.
Thanks for the report. This is a duplicate of a few prior reports (#4475, #4467, #4452, #4522), which has already been fixed and released so I am going to close.
The bug has existed for a while, and the fix for this is available starting from v1.4.26 so I don't think this will justify any kind of emergency backport/rust patch release on stable. In the interim you could consider using nightly (at least temporarily) if that's a possibility for you, so that you could get a newer version that has the fix (the latest nightly is v1.4.30), or alternatively perhaps building from source or grabbing the binaries from the GitHub release (more info here).
Otherwise you may just need to add #[rustfmt::skip] attributes and wait for the next stable release
Running rustfmt on this snippet of code:
Rewrites it to the following, inserting two additional opening brackets
{
:To Reproduce
For a minimal working example, I created a new
lib
project with the followinglib.rs
file (gist):This project builds before
cargo fmt
but fails to build after:The following is the diff after
cargo fmt
Expected behavior
Rewrites for whitespace, without additional brackets:
Meta
cargo fmt
The text was updated successfully, but these errors were encountered: