-
Notifications
You must be signed in to change notification settings - Fork 896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"panicked at 'bad span: .
: `'" when formatting
tuple.0.0`
#4355
Comments
I think the rustc AST may be broken. I just ran Anyway, I think the AST would have to be fixed because rustfmt relies on it to deconstruct the chain that should be formatted. |
Can confirm I just hit this issue as well. |
It seems that spans related to nested tuples are imprecise.
|
I have the following code which compiles. struct Baz{val: i32}
struct Bar(Baz);
struct Foo(Bar);
fn main() {
let x = Foo(Bar(Baz{val:1}));
x.0.0.val;
} cargo fmt
thread 'main' panicked at 'bad span: `.`: ``', src/tools/rustfmt/src/source_map.rs:52:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace On another machine, rustfmt gives rust-lang/rust#71322 |
This should be fixed in rust-lang/rust#77774, but needs confirmation. |
rustc_parse: More precise spans for `tuple.0.0` This should help with rust-lang/rustfmt#4355, but I haven't verified, cc `@calebcartwright.`
This doesn't seem to be fixed. The same playground link in the original post still panics on rustfmt. When I run locally on the repro example: fn main() {
let _ = ((1,),).0.0;
} With nightly on linux:
I get this:
|
@mk12 - this is fixed but we haven't been able to get it released yet due to various blockers upstream |
For those tracking here, this is fixed from v1.4.23 onward, and v1.4.24 is available in the latest nightly. However, please note that for historical reasons (that predate the semi-recent rustc changes) rustfmt formats these with a space inserted to prevent syntax errors (#1063). Due to rustfmt's stability guarantee, we cannot change that default behavior as it would break existing formatting. If you find that space to be problematic, then you can opt into the v2 formatting by adding |
As of 2024-11-27, Configuring Rustfmt has deprecated the
|
Describe the bug
The
tuple.0.0
syntax, whose support was recently merged to rustc (rust-lang/rust#71322), causes rustfmt to panic.To Reproduce
Playground Link
Backtrace
Expected behavior
rustfmt completes without panicking.
Meta
rustfmt 1.4.19-nightly (cef1c0d5 2020-07-21)
rustfmt +nightly-2020-07-27 filename.rs
The text was updated successfully, but these errors were encountered: