about summary refs log tree commit diff
path: root/compiler/rustc_infer/src/infer
diff options
context:
space:
mode:
authorCameron Steffen <cam.steffen94@gmail.com>2021-07-30 11:30:12 -0500
committerCameron Steffen <cam.steffen94@gmail.com>2021-08-30 20:18:42 -0500
commit2f4e86b9ef457ff7b465e73e3aaabfcaa1d9d8e1 (patch)
tree0a3ddf2ab5a4753d2b99b64742019c5fde1b5c7f /compiler/rustc_infer/src/infer
parentcb4439a3150308490a00773aa4f2a5ef23586a42 (diff)
downloadrust-2f4e86b9ef457ff7b465e73e3aaabfcaa1d9d8e1.tar.gz
rust-2f4e86b9ef457ff7b465e73e3aaabfcaa1d9d8e1.zip
Enforce diverging let...else
Diffstat (limited to 'compiler/rustc_infer/src/infer')
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index 299dcf5f17a..d54933841fd 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -781,6 +781,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                     );
                 }
             }
+            ObligationCauseCode::LetElse => {
+                err.help("try adding a diverging expression, such as `return` or `panic!(..)`");
+                err.help("...or use `match` instead of `let...else`");
+            }
             _ => (),
         }
     }
@@ -2592,6 +2596,7 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
             }
             IfExpression { .. } => Error0308("`if` and `else` have incompatible types"),
             IfExpressionWithNoElse => Error0317("`if` may be missing an `else` clause"),
+            LetElse => Error0308("`else` clause of `let...else` does not diverge"),
             MainFunctionType => Error0580("`main` function has wrong type"),
             StartFunctionType => Error0308("`#[start]` function has wrong type"),
             IntrinsicType => Error0308("intrinsic has wrong type"),