]> git.lizzy.rs Git - rust.git/commitdiff
Do not suggest `let_else` if no bindings would be introduced
authorEsteban Kuber <esteban@kuber.com.ar>
Tue, 8 Mar 2022 17:20:05 +0000 (17:20 +0000)
committerEsteban Kuber <esteban@kuber.com.ar>
Tue, 8 Mar 2022 17:20:05 +0000 (17:20 +0000)
compiler/rustc_mir_build/src/thir/pattern/check_match.rs
src/test/ui/consts/const-match-check.eval1.stderr
src/test/ui/consts/const-match-check.eval2.stderr
src/test/ui/consts/const-match-check.matchck.stderr
src/test/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr
src/test/ui/pattern/usefulness/non-exhaustive-defined-here.stderr
src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr

index dae313da8d993c6cfd161bd3bfd35f7a7c8094ab..c94da838680e075cc4c2c049fe6bf3886b229ce4 100644 (file)
@@ -330,7 +330,7 @@ fn check_irrefutable(&self, pat: &'tcx Pat<'tcx>, origin: &str, sp: Option<Span>
                     ],
                     Applicability::HasPlaceholders,
                 );
-                if cx.tcx.sess.is_nightly_build() {
+                if !bindings.is_empty() && cx.tcx.sess.is_nightly_build() {
                     err.span_suggestion_verbose(
                         semi_span.shrink_to_lo(),
                         &format!(
index 08ee800f138d2478f4f041d8f4f203d34ae2c43c..6e61dbbd8eee3906a3bb8b50131dff54d2f410b2 100644 (file)
@@ -11,10 +11,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     A = { if let 0 = 0 { todo!() } 0 },
    |           ++           ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     A = { let 0 = 0 else { todo!() }; 0 },
-   |                     ++++++++++++++++
 
 error: aborting due to previous error
 
index 579cb7e780007faadd230ba5bee1bd2e3273d02c..1b3b6e06c3df611e98de7a42ec2d342ac19fb1b6 100644 (file)
@@ -11,10 +11,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     let x: [i32; { if let 0 = 0 { todo!() } 0 }] = [];
    |                    ++           ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     let x: [i32; { let 0 = 0 else { todo!() }; 0 }] = [];
-   |                              ++++++++++++++++
 
 error: aborting due to previous error
 
index f89bbc0d42234447a3d195300f54c8165cf26679..bc8edfa7af9f488dacfabc9dffe769609f0ce517 100644 (file)
@@ -11,10 +11,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL | const X: i32 = { if let 0 = 0 { todo!() } 0 };
    |                  ++           ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL | const X: i32 = { let 0 = 0 else { todo!() }; 0 };
-   |                            ++++++++++++++++
 
 error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:8:23
@@ -29,10 +25,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL | static Y: i32 = { if let 0 = 0 { todo!() } 0 };
    |                   ++           ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL | static Y: i32 = { let 0 = 0 else { todo!() }; 0 };
-   |                             ++++++++++++++++
 
 error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:13:26
@@ -47,10 +39,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     const X: i32 = { if let 0 = 0 { todo!() } 0 };
    |                      ++           ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     const X: i32 = { let 0 = 0 else { todo!() }; 0 };
-   |                                ++++++++++++++++
 
 error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:19:26
@@ -65,10 +53,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     const X: i32 = { if let 0 = 0 { todo!() } 0 };
    |                      ++           ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     const X: i32 = { let 0 = 0 else { todo!() }; 0 };
-   |                                ++++++++++++++++
 
 error: aborting due to 4 previous errors
 
index aa1aa4434c3fa4e84c2288fd4d1025de87592ce3..95b22ac059482fa52a97051b5ca6050321410f74 100644 (file)
@@ -11,10 +11,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     if let (0 | (1 | 2)) = 0 { todo!() }
    |     ++                       ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     let (0 | (1 | 2)) = 0 else { todo!() };
-   |                           ++++++++++++++++
 
 error[E0004]: non-exhaustive patterns: `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered
   --> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:3:11
index f7dc070f802489986a765057c9d49784f750a7be..0f06c31c468b148035cb1d88313079cd27b00bba 100644 (file)
@@ -46,10 +46,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     if let E::A = e { todo!() }
    |     ++              ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     let E::A = e else { todo!() };
-   |                  ++++++++++++++++
 
 error[E0004]: non-exhaustive patterns: `&B` and `&C` not covered
   --> $DIR/non-exhaustive-defined-here.rs:52:11
@@ -99,10 +95,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     if let E::A = e { todo!() }
    |     ++              ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     let E::A = e else { todo!() };
-   |                  ++++++++++++++++
 
 error[E0004]: non-exhaustive patterns: `&&mut &B` and `&&mut &C` not covered
   --> $DIR/non-exhaustive-defined-here.rs:66:11
@@ -152,10 +144,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     if let E::A = e { todo!() }
    |     ++              ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     let E::A = e else { todo!() };
-   |                  ++++++++++++++++
 
 error[E0004]: non-exhaustive patterns: `None` not covered
   --> $DIR/non-exhaustive-defined-here.rs:92:11
index e3ffc092327acc8bf0dfe47975010cde9ec8d5a4..d1dacc822e942e49856d95c4bad4d01e48c3a99e 100644 (file)
@@ -19,10 +19,6 @@ help: you might want to use `if let` to ignore the variants that aren't matched
    |
 LL |     if let (1, (Some(1), 2..=3)) = (1, (None, 2)) { todo!() }
    |     ++                                            ~~~~~~~~~~~
-help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variants that aren't matched
-   |
-LL |     let (1, (Some(1), 2..=3)) = (1, (None, 2)) else { todo!() };
-   |                                                ++++++++++++++++
 
 error: aborting due to 2 previous errors