about summary refs log tree commit diff
path: root/src/test/ui/consts
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-10-09 12:25:48 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-10-09 12:25:48 -0700
commit4bb1592402003184cd73c6ee5b135df084ea5abc (patch)
tree7653b07f00f3f4d9a901bd1ae6852a2013ef0f81 /src/test/ui/consts
parentec557aa8180ca08ff749793b3d42383618b96044 (diff)
downloadrust-4bb1592402003184cd73c6ee5b135df084ea5abc.tar.gz
rust-4bb1592402003184cd73c6ee5b135df084ea5abc.zip
Suggest `if let` on `let` refutable binding
Diffstat (limited to 'src/test/ui/consts')
-rw-r--r--src/test/ui/consts/const-match-check.eval1.stderr7
-rw-r--r--src/test/ui/consts/const-match-check.eval2.stderr7
-rw-r--r--src/test/ui/consts/const-match-check.matchck.stderr28
3 files changed, 42 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-match-check.eval1.stderr b/src/test/ui/consts/const-match-check.eval1.stderr
index 24d2e3ce539..087cc3c86a6 100644
--- a/src/test/ui/consts/const-match-check.eval1.stderr
+++ b/src/test/ui/consts/const-match-check.eval1.stderr
@@ -3,6 +3,13 @@ error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1
    |
 LL |     A = { let 0 = 0; 0 },
    |               ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |
+   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+help: you might want to use `if let` to ignore the variant that isn't matched
+   |
+LL |     A = { if let 0 = 0 { /* */ } 0 },
+   |           ^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/consts/const-match-check.eval2.stderr b/src/test/ui/consts/const-match-check.eval2.stderr
index 5d59d06f798..80d9f794bc1 100644
--- a/src/test/ui/consts/const-match-check.eval2.stderr
+++ b/src/test/ui/consts/const-match-check.eval2.stderr
@@ -3,6 +3,13 @@ error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1
    |
 LL |     let x: [i32; { let 0 = 0; 0 }] = [];
    |                        ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |
+   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+help: you might want to use `if let` to ignore the variant that isn't matched
+   |
+LL |     let x: [i32; { if let 0 = 0 { /* */ } 0 }] = [];
+   |                    ^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/consts/const-match-check.matchck.stderr b/src/test/ui/consts/const-match-check.matchck.stderr
index 6d74c26f9f7..e6b2f212bb4 100644
--- a/src/test/ui/consts/const-match-check.matchck.stderr
+++ b/src/test/ui/consts/const-match-check.matchck.stderr
@@ -3,24 +3,52 @@ error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1
    |
 LL | const X: i32 = { let 0 = 0; 0 };
    |                      ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |
+   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+help: you might want to use `if let` to ignore the variant that isn't matched
+   |
+LL | const X: i32 = { if let 0 = 0 { /* */ } 0 };
+   |                  ^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
   --> $DIR/const-match-check.rs:8:23
    |
 LL | static Y: i32 = { let 0 = 0; 0 };
    |                       ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |
+   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+help: you might want to use `if let` to ignore the variant that isn't matched
+   |
+LL | static Y: i32 = { if let 0 = 0 { /* */ } 0 };
+   |                   ^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
   --> $DIR/const-match-check.rs:13:26
    |
 LL |     const X: i32 = { let 0 = 0; 0 };
    |                          ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |
+   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+help: you might want to use `if let` to ignore the variant that isn't matched
+   |
+LL |     const X: i32 = { if let 0 = 0 { /* */ } 0 };
+   |                      ^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
   --> $DIR/const-match-check.rs:19:26
    |
 LL |     const X: i32 = { let 0 = 0; 0 };
    |                          ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |
+   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+help: you might want to use `if let` to ignore the variant that isn't matched
+   |
+LL |     const X: i32 = { if let 0 = 0 { /* */ } 0 };
+   |                      ^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 4 previous errors