diff options
| author | Yuki Okushi <yuki.okushi@huawei.com> | 2021-06-19 11:46:14 +0900 |
|---|---|---|
| committer | Yuki Okushi <yuki.okushi@huawei.com> | 2021-06-19 11:47:15 +0900 |
| commit | bc243a7f5597dbc6bd6947e9d799ed9fba428634 (patch) | |
| tree | 7cbd336934e8dd1a6429c1a7be5bd92b1f091301 /src/test/ui/pattern | |
| parent | ec57c60c50de4f601a5dbe80e663388058e6e527 (diff) | |
| download | rust-bc243a7f5597dbc6bd6947e9d799ed9fba428634.tar.gz rust-bc243a7f5597dbc6bd6947e9d799ed9fba428634.zip | |
Refactor `PatternError` structure
Diffstat (limited to 'src/test/ui/pattern')
4 files changed, 46 insertions, 14 deletions
diff --git a/src/test/ui/pattern/issue-68394-let-pat-runtime-value.rs b/src/test/ui/pattern/issue-68394-let-pat-runtime-value.rs deleted file mode 100644 index f10a7f2d8a5..00000000000 --- a/src/test/ui/pattern/issue-68394-let-pat-runtime-value.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - let x = 255u8; - let 0u8..=x = 0; - //~^ ERROR runtime values cannot be referenced in patterns -} diff --git a/src/test/ui/pattern/issue-68394-let-pat-runtime-value.stderr b/src/test/ui/pattern/issue-68394-let-pat-runtime-value.stderr deleted file mode 100644 index c1508bd71ff..00000000000 --- a/src/test/ui/pattern/issue-68394-let-pat-runtime-value.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/pattern/non-constant-in-const-path.rs b/src/test/ui/pattern/non-constant-in-const-path.rs new file mode 100644 index 00000000000..3918485bacb --- /dev/null +++ b/src/test/ui/pattern/non-constant-in-const-path.rs @@ -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 + }; +} diff --git a/src/test/ui/pattern/non-constant-in-const-path.stderr b/src/test/ui/pattern/non-constant-in-const-path.stderr new file mode 100644 index 00000000000..53c3974f780 --- /dev/null +++ b/src/test/ui/pattern/non-constant-in-const-path.stderr @@ -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`. |
