Refactor PatternError structure
This commit is contained in:
parent
ec57c60c50
commit
bc243a7f55
9 changed files with 50 additions and 54 deletions
|
|
@ -1,10 +0,0 @@
|
|||
fn main() {
|
||||
let i = 5;
|
||||
let index = 6;
|
||||
|
||||
match i {
|
||||
0..=index => println!("winner"),
|
||||
//~^ ERROR runtime values cannot be referenced in patterns
|
||||
_ => println!("hello"),
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0080]: runtime values cannot be referenced in patterns
|
||||
--> $DIR/issue-27895.rs:6:13
|
||||
|
|
||||
LL | 0..=index => println!("winner"),
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
fn main() {
|
||||
let x = 0;
|
||||
match 1 {
|
||||
0 ..= x => {}
|
||||
//~^ ERROR runtime values cannot be referenced in patterns
|
||||
};
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0080]: runtime values cannot be referenced in patterns
|
||||
--> $DIR/non-constant-in-const-path.rs:4:15
|
||||
|
|
||||
LL | 0 ..= x => {}
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
fn main() {
|
||||
let x = 255u8;
|
||||
let 0u8..=x = 0;
|
||||
//~^ ERROR runtime values cannot be referenced in patterns
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0080]: runtime values cannot be referenced in patterns
|
||||
--> $DIR/issue-68394-let-pat-runtime-value.rs:3:15
|
||||
|
|
||||
LL | let 0u8..=x = 0;
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
18
src/test/ui/pattern/non-constant-in-const-path.rs
Normal file
18
src/test/ui/pattern/non-constant-in-const-path.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Checks if we emit `PatternError`s correctly.
|
||||
// This is also a regression test for #27895 and #68394.
|
||||
|
||||
static FOO: u8 = 10;
|
||||
|
||||
fn main() {
|
||||
let x = 0;
|
||||
let 0u8..=x = 0;
|
||||
//~^ ERROR: runtime values cannot be referenced in patterns
|
||||
let 0u8..=FOO = 0;
|
||||
//~^ ERROR: statics cannot be referenced in patterns
|
||||
match 1 {
|
||||
0 ..= x => {}
|
||||
//~^ ERROR: runtime values cannot be referenced in patterns
|
||||
0 ..= FOO => {}
|
||||
//~^ ERROR: statics cannot be referenced in patterns
|
||||
};
|
||||
}
|
||||
28
src/test/ui/pattern/non-constant-in-const-path.stderr
Normal file
28
src/test/ui/pattern/non-constant-in-const-path.stderr
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
error[E0080]: runtime values cannot be referenced in patterns
|
||||
--> $DIR/non-constant-in-const-path.rs:8:15
|
||||
|
|
||||
LL | let 0u8..=x = 0;
|
||||
| ^
|
||||
|
||||
error[E0158]: statics cannot be referenced in patterns
|
||||
--> $DIR/non-constant-in-const-path.rs:10:15
|
||||
|
|
||||
LL | let 0u8..=FOO = 0;
|
||||
| ^^^
|
||||
|
||||
error[E0080]: runtime values cannot be referenced in patterns
|
||||
--> $DIR/non-constant-in-const-path.rs:13:15
|
||||
|
|
||||
LL | 0 ..= x => {}
|
||||
| ^
|
||||
|
||||
error[E0158]: statics cannot be referenced in patterns
|
||||
--> $DIR/non-constant-in-const-path.rs:15:15
|
||||
|
|
||||
LL | 0 ..= FOO => {}
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0080, E0158.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue