about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2024-08-19 21:08:18 +0200
committerNadrieril <nadrieril+git@gmail.com>2024-08-19 21:57:37 +0200
commitefb28bdd90cf7b4ef6d436edaca8f394724fb604 (patch)
treefd39643995558d2f7d8a4e8194820d3638307d31 /compiler/rustc_mir_build/src
parent25964b541e5671de044fd01d058a45bb92b75d1e (diff)
downloadrust-efb28bdd90cf7b4ef6d436edaca8f394724fb604.tar.gz
rust-efb28bdd90cf7b4ef6d436edaca8f394724fb604.zip
Add a note with a link to explain empty types
Diffstat (limited to 'compiler/rustc_mir_build/src')
-rw-r--r--compiler/rustc_mir_build/src/errors.rs2
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/check_match.rs2
2 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs
index 34577f102d1..a45a0311e32 100644
--- a/compiler/rustc_mir_build/src/errors.rs
+++ b/compiler/rustc_mir_build/src/errors.rs
@@ -588,6 +588,8 @@ pub(crate) struct UnreachablePattern<'tcx> {
     pub(crate) span: Option<Span>,
     #[subdiagnostic]
     pub(crate) matches_no_values: Option<UnreachableMatchesNoValues<'tcx>>,
+    #[note(mir_build_unreachable_uninhabited_note)]
+    pub(crate) uninhabited_note: Option<()>,
     #[label(mir_build_unreachable_covered_by_catchall)]
     pub(crate) covered_by_catchall: Option<Span>,
     #[label(mir_build_unreachable_covered_by_one)]
diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
index 85b9dacb129..a948e5d0c21 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
@@ -921,6 +921,7 @@ fn report_unreachable_pattern<'p, 'tcx>(
     let mut lint = UnreachablePattern {
         span: Some(pat_span),
         matches_no_values: None,
+        uninhabited_note: None,
         covered_by_catchall: None,
         covered_by_one: None,
         covered_by_many: None,
@@ -929,6 +930,7 @@ fn report_unreachable_pattern<'p, 'tcx>(
         [] => {
             // Empty pattern; we report the uninhabited type that caused the emptiness.
             lint.span = None; // Don't label the pattern itself
+            lint.uninhabited_note = Some(()); // Give a link about empty types
             pat.walk(&mut |subpat| {
                 let ty = **subpat.ty();
                 if cx.is_uninhabited(ty) {