-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
thread 'rustc' panicked at 'attempt to subtract with overflow', rust/compiler/rustc_resolve/src/diagnostics.rs:458:49 #90878
Labels
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
Badel2
added
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Nov 13, 2021
@rustbot claim |
Noratrieb
added a commit
to Noratrieb/rust
that referenced
this issue
Nov 15, 2021
This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const. I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong. Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Nov 16, 2021
…r=estebank Fix `non-constant value` ICE (rust-lang#90878) This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const. I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong. Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE. Asking Esteban to review since he was the last one to change the relevant code. r? `@estebank` Fixes rust-lang#90878
Noratrieb
added a commit
to Noratrieb/rust
that referenced
this issue
Nov 16, 2021
…ewline I cannot provide a test for that thanks to tidy.
Noratrieb
added a commit
to Noratrieb/rust
that referenced
this issue
Nov 17, 2021
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Nov 20, 2021
…r=estebank Fix `non-constant value` ICE (rust-lang#90878) This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const. I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong. Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE. Asking Esteban to review since he was the last one to change the relevant code. r? `@estebank` Fixes rust-lang#90878
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Nov 20, 2021
…askrgr Rollup of 5 pull requests Successful merges: - rust-lang#90575 (Improve suggestions for compatible variants on type mismatch.) - rust-lang#90628 (Clarify error messages caused by re-exporting `pub(crate)` visibility to outside) - rust-lang#90930 (Fix `non-constant value` ICE (rust-lang#90878)) - rust-lang#90983 (Make scrollbar in the sidebar always visible for visual consistency) - rust-lang#91021 (Elaborate `Future::Output` when printing opaque `impl Future` type) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
When rustc is compiled with debug assertions, this results in a subtract with overflow on this line:
rust/compiler/rustc_resolve/src/diagnostics.rs
Line 458 in 1b12d01
And if compiled without debug assertions, you get a warning "Invalid span".
Introduced in #80801
Affected versions: stable 1.56.1, nightly 2021-11-12
Backtrace
With debug assertions:
Without debug assertions, it only shows a warning "Invalid span":
This issue was found thanks to fuzz-rustc, but the actual minimized code was hard to understand (
#![l=|x|[b;x
) so I unminimized it a bit. A related issue I found is that the span is wrong when there is whitespace between "let" and "x" here:The text was updated successfully, but these errors were encountered: