about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/consts/const-pattern-irrefutable.stderr24
-rw-r--r--src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs10
-rw-r--r--src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr15
3 files changed, 46 insertions, 3 deletions
diff --git a/src/test/ui/consts/const-pattern-irrefutable.stderr b/src/test/ui/consts/const-pattern-irrefutable.stderr
index 06f5e90d2f1..4814aa9a5b2 100644
--- a/src/test/ui/consts/const-pattern-irrefutable.stderr
+++ b/src/test/ui/consts/const-pattern-irrefutable.stderr
@@ -1,20 +1,38 @@
 error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX` not covered
   --> $DIR/const-pattern-irrefutable.rs:12:9
    |
+LL | const a: u8 = 2;
+   | ---------------- constant defined here
+...
 LL |     let a = 4;
-   |         ^ interpreted as a constant pattern, not new variable
+   |         ^
+   |         |
+   |         interpreted as a constant pattern, not a new variable
+   |         help: introduce a variable instead: `a_var`
 
 error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX` not covered
   --> $DIR/const-pattern-irrefutable.rs:13:9
    |
+LL |     pub const b: u8 = 2;
+   |     -------------------- constant defined here
+...
 LL |     let c = 4;
-   |         ^ interpreted as a constant pattern, not new variable
+   |         ^
+   |         |
+   |         interpreted as a constant pattern, not a new variable
+   |         help: introduce a variable instead: `c_var`
 
 error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX` not covered
   --> $DIR/const-pattern-irrefutable.rs:14:9
    |
+LL |     pub const d: u8 = 2;
+   |     -------------------- constant defined here
+...
 LL |     let d = 4;
-   |         ^ interpreted as a constant pattern, not new variable
+   |         ^
+   |         |
+   |         interpreted as a constant pattern, not a new variable
+   |         help: introduce a variable instead: `d_var`
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs
new file mode 100644
index 00000000000..2a11871db8e
--- /dev/null
+++ b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs
@@ -0,0 +1,10 @@
+fn main() {
+    let A = 3;
+    //~^ ERROR refutable pattern in local binding: `std::i32::MIN..=1i32` and
+    //~| interpreted as a constant pattern, not a new variable
+    //~| HELP introduce a variable instead
+    //~| SUGGESTION a_var
+
+    const A: i32 = 2;
+    //~^ constant defined here
+}
diff --git a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr
new file mode 100644
index 00000000000..fc17199bf91
--- /dev/null
+++ b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr
@@ -0,0 +1,15 @@
+error[E0005]: refutable pattern in local binding: `std::i32::MIN..=1i32` and `3i32..=std::i32::MAX` not covered
+  --> $DIR/const-pat-non-exaustive-let-new-var.rs:2:9
+   |
+LL |     let A = 3;
+   |         ^
+   |         |
+   |         interpreted as a constant pattern, not a new variable
+   |         help: introduce a variable instead: `a_var`
+...
+LL |     const A: i32 = 2;
+   |     ----------------- constant defined here
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0005`.