forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#91607 - FabianWolff:issue-91560-const-span,…
… r=jackh726 Make `span_extend_to_prev_str()` more robust Fixes rust-lang#91560. The logic in `span_extend_to_prev_str()` is currently quite brittle and fails if there is extra whitespace or something else in between, and it also should return an `Option` but doesn't currently.
- Loading branch information
Showing
7 changed files
with
123 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Regression test for issue #91560. | ||
|
||
// run-rustfix | ||
|
||
#![allow(unused,non_upper_case_globals)] | ||
|
||
fn foo() { | ||
const length: usize = 2; | ||
//~^ HELP: consider using `const` | ||
let arr = [0; length]; | ||
//~^ ERROR: attempt to use a non-constant value in a constant [E0435] | ||
} | ||
|
||
fn bar() { | ||
const length: usize = 2; | ||
//~^ HELP: consider using `const` | ||
let arr = [0; length]; | ||
//~^ ERROR: attempt to use a non-constant value in a constant [E0435] | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Regression test for issue #91560. | ||
|
||
// run-rustfix | ||
|
||
#![allow(unused,non_upper_case_globals)] | ||
|
||
fn foo() { | ||
let mut length: usize = 2; | ||
//~^ HELP: consider using `const` | ||
let arr = [0; length]; | ||
//~^ ERROR: attempt to use a non-constant value in a constant [E0435] | ||
} | ||
|
||
fn bar() { | ||
let length: usize = 2; | ||
//~^ HELP: consider using `const` | ||
let arr = [0; length]; | ||
//~^ ERROR: attempt to use a non-constant value in a constant [E0435] | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0435]: attempt to use a non-constant value in a constant | ||
--> $DIR/issue-91560.rs:10:19 | ||
| | ||
LL | let mut length: usize = 2; | ||
| -------------- help: consider using `const` instead of `let`: `const length` | ||
LL | | ||
LL | let arr = [0; length]; | ||
| ^^^^^^ non-constant value | ||
|
||
error[E0435]: attempt to use a non-constant value in a constant | ||
--> $DIR/issue-91560.rs:17:19 | ||
| | ||
LL | let length: usize = 2; | ||
| ------------ help: consider using `const` instead of `let`: `const length` | ||
LL | | ||
LL | let arr = [0; length]; | ||
| ^^^^^^ non-constant value | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0435`. |