]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_middle/src/lint.rs
Rollup merge of #94566 - yanganto:show-ignore-message, r=m-ou-se
[rust.git] / compiler / rustc_middle / src / lint.rs
index dc1fe5f2b0836d947352eb7f21e941bc69114db4..1f0cd907f8aceda2b4cb9254f5f484e4b3ab66e2 100644 (file)
@@ -12,7 +12,7 @@
     builtin::{self, FORBIDDEN_LINT_GROUPS},
     FutureIncompatibilityReason, Level, Lint, LintExpectationId, LintId,
 };
-use rustc_session::{DiagnosticMessageId, Session};
+use rustc_session::Session;
 use rustc_span::hygiene::MacroKind;
 use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan};
 use rustc_span::{symbol, Span, Symbol, DUMMY_SP};
@@ -245,7 +245,6 @@ pub fn forget_guarantee(self) -> LintDiagnosticBuilder<'a, ()> {
 }
 
 pub fn explain_lint_level_source(
-    sess: &Session,
     lint: &'static Lint,
     level: Level,
     src: LintLevelSource,
@@ -254,11 +253,7 @@ pub fn explain_lint_level_source(
     let name = lint.name_lower();
     match src {
         LintLevelSource::Default => {
-            sess.diag_note_once(
-                err,
-                DiagnosticMessageId::from(lint),
-                &format!("`#[{}({})]` on by default", level.as_str(), name),
-            );
+            err.note_once(&format!("`#[{}({})]` on by default", level.as_str(), name));
         }
         LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
             let flag = match orig_level {
@@ -273,46 +268,29 @@ pub fn explain_lint_level_source(
             };
             let hyphen_case_lint_name = name.replace('_', "-");
             if lint_flag_val.as_str() == name {
-                sess.diag_note_once(
-                    err,
-                    DiagnosticMessageId::from(lint),
-                    &format!(
-                        "requested on the command line with `{} {}`",
-                        flag, hyphen_case_lint_name
-                    ),
-                );
+                err.note_once(&format!(
+                    "requested on the command line with `{} {}`",
+                    flag, hyphen_case_lint_name
+                ));
             } else {
                 let hyphen_case_flag_val = lint_flag_val.as_str().replace('_', "-");
-                sess.diag_note_once(
-                    err,
-                    DiagnosticMessageId::from(lint),
-                    &format!(
-                        "`{} {}` implied by `{} {}`",
-                        flag, hyphen_case_lint_name, flag, hyphen_case_flag_val
-                    ),
-                );
+                err.note_once(&format!(
+                    "`{} {}` implied by `{} {}`",
+                    flag, hyphen_case_lint_name, flag, hyphen_case_flag_val
+                ));
             }
         }
         LintLevelSource::Node(lint_attr_name, src, reason) => {
             if let Some(rationale) = reason {
                 err.note(rationale.as_str());
             }
-            sess.diag_span_note_once(
-                err,
-                DiagnosticMessageId::from(lint),
-                src,
-                "the lint level is defined here",
-            );
+            err.span_note_once(src, "the lint level is defined here");
             if lint_attr_name.as_str() != name {
                 let level_str = level.as_str();
-                sess.diag_note_once(
-                    err,
-                    DiagnosticMessageId::from(lint),
-                    &format!(
-                        "`#[{}({})]` implied by `#[{}({})]`",
-                        level_str, name, level_str, lint_attr_name
-                    ),
-                );
+                err.note_once(&format!(
+                    "`#[{}({})]` implied by `#[{}({})]`",
+                    level_str, name, level_str, lint_attr_name
+                ));
             }
         }
     }
@@ -412,7 +390,7 @@ fn struct_lint_level_impl<'s, 'd>(
             return;
         }
 
-        explain_lint_level_source(sess, lint, level, src, &mut err);
+        explain_lint_level_source(lint, level, src, &mut err);
 
         let name = lint.name_lower();
         let is_force_warn = matches!(level, Level::ForceWarn);