about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
-rw-r--r--compiler/rustc_hir_analysis/src/check/errs.rs28
-rw-r--r--compiler/rustc_hir_analysis/src/errors.rs28
2 files changed, 17 insertions, 39 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/errs.rs b/compiler/rustc_hir_analysis/src/check/errs.rs
index 87a1f3d3425..4a7ace274c5 100644
--- a/compiler/rustc_hir_analysis/src/check/errs.rs
+++ b/compiler/rustc_hir_analysis/src/check/errs.rs
@@ -1,6 +1,6 @@
 use rustc_hir as hir;
 use rustc_hir_pretty::qpath_to_string;
-use rustc_lint_defs::builtin::STATIC_MUT_REF;
+use rustc_lint_defs::builtin::STATIC_MUT_REFS;
 use rustc_middle::ty::TyCtxt;
 use rustc_span::Span;
 use rustc_type_ir::Mutability;
@@ -66,32 +66,24 @@ fn handle_static_mut_ref(
     hir_id: hir::HirId,
 ) {
     if e2024 {
-        let sugg = if mutable {
-            errors::StaticMutRefSugg::Mut { span, var }
+        let (sugg, shared) = if mutable {
+            (errors::StaticMutRefSugg::Mut { span, var }, "mutable")
         } else {
-            errors::StaticMutRefSugg::Shared { span, var }
+            (errors::StaticMutRefSugg::Shared { span, var }, "shared")
         };
-        tcx.sess.parse_sess.dcx.emit_err(errors::StaticMutRef { span, sugg });
+        tcx.sess.parse_sess.dcx.emit_err(errors::StaticMutRef { span, sugg, shared });
         return;
     }
 
-    let (label, sugg, shared) = if mutable {
-        (
-            errors::RefOfMutStaticLabel::Mut { span },
-            errors::RefOfMutStaticSugg::Mut { span, var },
-            "mutable ",
-        )
+    let (sugg, shared) = if mutable {
+        (errors::RefOfMutStaticSugg::Mut { span, var }, "mutable")
     } else {
-        (
-            errors::RefOfMutStaticLabel::Shared { span },
-            errors::RefOfMutStaticSugg::Shared { span, var },
-            "shared ",
-        )
+        (errors::RefOfMutStaticSugg::Shared { span, var }, "shared")
     };
     tcx.emit_node_span_lint(
-        STATIC_MUT_REF,
+        STATIC_MUT_REFS,
         hir_id,
         span,
-        errors::RefOfMutStatic { shared, why_note: (), label, sugg },
+        errors::RefOfMutStatic { span, sugg, shared },
     );
 }
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs
index 3bd7687a544..03ec8e163d6 100644
--- a/compiler/rustc_hir_analysis/src/errors.rs
+++ b/compiler/rustc_hir_analysis/src/errors.rs
@@ -1462,12 +1462,13 @@ pub struct OnlyCurrentTraitsPointerSugg<'a> {
 #[derive(Diagnostic)]
 #[diag(hir_analysis_static_mut_ref, code = E0796)]
 #[note]
-pub struct StaticMutRef {
+pub struct StaticMutRef<'a> {
     #[primary_span]
     #[label]
     pub span: Span,
     #[subdiagnostic]
     pub sugg: StaticMutRefSugg,
+    pub shared: &'a str,
 }
 
 #[derive(Subdiagnostic)]
@@ -1498,30 +1499,15 @@ pub enum StaticMutRefSugg {
 
 // STATIC_MUT_REF lint
 #[derive(LintDiagnostic)]
-#[diag(hir_analysis_static_mut_ref_lint)]
+#[diag(hir_analysis_static_mut_refs_lint)]
 #[note]
+#[note(hir_analysis_why_note)]
 pub struct RefOfMutStatic<'a> {
-    pub shared: &'a str,
-    #[note(hir_analysis_why_note)]
-    pub why_note: (),
-    #[subdiagnostic]
-    pub label: RefOfMutStaticLabel,
+    #[label]
+    pub span: Span,
     #[subdiagnostic]
     pub sugg: RefOfMutStaticSugg,
-}
-
-#[derive(Subdiagnostic)]
-pub enum RefOfMutStaticLabel {
-    #[label(hir_analysis_label)]
-    Shared {
-        #[primary_span]
-        span: Span,
-    },
-    #[label(hir_analysis_label_mut)]
-    Mut {
-        #[primary_span]
-        span: Span,
-    },
+    pub shared: &'a str,
 }
 
 #[derive(Subdiagnostic)]