rust/src/test/ui/consts/issue-90878.stderr
Nilstrieb d64aea65ad Fix non-constant value ICE (#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.
2021-11-15 20:40:29 +01:00

12 lines
316 B
Plaintext

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-90878.rs:2:20
|
LL | |x: usize| [0; x];
| - ^
| |
| this would need to be a `const`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0435`.