Skip to content
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

Panic in SourceAnnotation when using hard_tabs = true #6442

Open
lbfalvy opened this issue Jan 12, 2025 · 9 comments
Open

Panic in SourceAnnotation when using hard_tabs = true #6442

lbfalvy opened this issue Jan 12, 2025 · 9 comments
Labels
bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce

Comments

@lbfalvy
Copy link

lbfalvy commented Jan 12, 2025

Here's the code it died on

https://github.com/lbfalvy/orchid/tree/e0d246fe1fa75405305ec4390ba6815049246726

Logfile the panic asked me to attach

rustc-ice-2025-01-12T01_00_58-10688.txt

@lbfalvy lbfalvy changed the title Compiler panic Panic on Windows Jan 12, 2025
@lbfalvy
Copy link
Author

lbfalvy commented Jan 12, 2025

I tried a freshly installed nightly toolchain on Ubuntu and got the same error. Same codebase, here's the crash report:

rustc-ice-2025-01-12T17_57_36-6548.txt

@lbfalvy lbfalvy changed the title Panic on Windows Panic "SourceAnnotation range is bigger than source length" Jan 12, 2025
@ytmimi
Copy link
Contributor

ytmimi commented Jan 13, 2025

@lbfalvy can you please get this down to a minimal example that can be used to reproduce the error. Also, it would be good to know the exact version of rustfmt that you're using and if you're using any non-default rustfmt configs.

@ytmimi ytmimi added the needs-mcve needs a Minimal Complete and Verifiable Example label Jan 13, 2025
@lbfalvy
Copy link
Author

lbfalvy commented Jan 13, 2025

@ytmimi All done, it's very similar to other SourceAnnotation bugs but I can't find the specific issue that had a really long print statement as a minimal example.

For completeness' sake, here's my minimal example.

repo: https://github.com/lbfalvy/orchid/tree/rustfmt-minimal-crash

It's just one file:

// src/main.rs
pub fn main() {
	println!(
		"Reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
	)
}

rustfmt options:

# rustfmt.toml
unstable_features = true
style_edition = "2024"

hard_tabs = true
# the following two are unstable
error_on_line_overflow = true
error_on_unformatted = true

I checked, all three options are necessary to trigger the panic, any other combination results in either a successful run or an explicit formatting error.

rustfmt version according to cargo fmt -- --version:

rustfmt 1.8.0-nightly (48a426eca9 2025-01-12)

And finally the crash file

rustc-ice-2025-01-13T14_58_18-35820.txt

@ytmimi
Copy link
Contributor

ytmimi commented Jan 13, 2025

Thank you for the extra info!

@ytmimi
Copy link
Contributor

ytmimi commented Jan 13, 2025

Because this issue involves tabs, I think this is related to #4968 (comment)

@ytmimi ytmimi changed the title Panic "SourceAnnotation range is bigger than source length" Panic in SourceAnnotation when using hard_tabs = true Jan 13, 2025
@ytmimi ytmimi added bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce and removed needs-mcve needs a Minimal Complete and Verifiable Example labels Jan 13, 2025
@lbfalvy
Copy link
Author

lbfalvy commented Jan 15, 2025

Just checked with main because I saw that #6391 got merged and it seems to be working fine. Thank you!

@ytmimi
Copy link
Contributor

ytmimi commented Jan 16, 2025

From local testing with rustfmt 1.8.0-nightly (d97c4fb 2025-01-13) this snippet from #6442 (comment) still panics with hard_tabs=true

@lbfalvy
Copy link
Author

lbfalvy commented Jan 16, 2025

@ytmimi right, then it looks like my minimal example wasn't accurate because the original full project now correctly reports an error instead of panicking.

@ytmimi
Copy link
Contributor

ytmimi commented Jan 16, 2025

I see. Either way, the MCVE you provided still panics, and I think that's a good enough reason to keep the issue open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

No branches or pull requests

2 participants