diff options
| author | Urgau <urgau@numericable.fr> | 2024-12-15 00:27:32 +0100 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2024-12-15 00:28:07 +0100 |
| commit | c448e35af57303fc5be1dabc4384c468439ee776 (patch) | |
| tree | a5fa200f069fb14e02e6d443f7f14c8917b3ae19 /compiler/rustc_lint/src/early.rs | |
| parent | ab780fa48aa49463301620ec825da3376c0171a3 (diff) | |
| download | rust-c448e35af57303fc5be1dabc4384c468439ee776.tar.gz rust-c448e35af57303fc5be1dabc4384c468439ee776.zip | |
Simplify `opt_span_lint` call in early diagnostic
Diffstat (limited to 'compiler/rustc_lint/src/early.rs')
| -rw-r--r-- | compiler/rustc_lint/src/early.rs | 40 |
1 files changed, 4 insertions, 36 deletions
diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 6d1081700d7..44f724225d9 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -8,16 +8,14 @@ use rustc_ast::ptr::P; use rustc_ast::visit::{self as ast_visit, Visitor, walk_list}; use rustc_ast::{self as ast, HasAttrs}; use rustc_data_structures::stack::ensure_sufficient_stack; -use rustc_errors::MultiSpan; use rustc_feature::Features; use rustc_middle::ty::{RegisteredTools, TyCtxt}; use rustc_session::Session; -use rustc_session::lint::{BufferedEarlyLint, BuiltinLintDiag, LintBuffer, LintPass}; +use rustc_session::lint::{BufferedEarlyLint, LintBuffer, LintPass}; use rustc_span::Span; use rustc_span::symbol::Ident; use tracing::debug; -use crate::Lint; use crate::context::{EarlyContext, LintContext, LintStore}; use crate::passes::{EarlyLintPass, EarlyLintPassObject}; @@ -35,38 +33,6 @@ pub struct EarlyContextAndPass<'a, 'b, T: EarlyLintPass> { pass: T, } -impl<T: EarlyLintPass> EarlyContextAndPass<'_, '_, T> { - /// Emit a lint at the appropriate level, with an associated span and an existing - /// diagnostic. - /// - /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature - #[rustc_lint_diagnostics] - pub fn span_lint_with_diagnostics( - &self, - lint: &'static Lint, - span: MultiSpan, - diagnostic: BuiltinLintDiag, - ) { - self.opt_span_lint_with_diagnostics(lint, Some(span), diagnostic); - } - - /// Emit a lint at the appropriate level, with an optional associated span and an existing - /// diagnostic. - /// - /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature - #[rustc_lint_diagnostics] - pub fn opt_span_lint_with_diagnostics( - &self, - lint: &'static Lint, - span: Option<MultiSpan>, - diagnostic: BuiltinLintDiag, - ) { - self.context.opt_span_lint(lint, span, |diag| { - diagnostics::decorate_lint(self.context.sess(), self.tcx, diagnostic, diag); - }); - } -} - impl<'a, 'b, T: EarlyLintPass> EarlyContextAndPass<'a, 'b, T> { // This always-inlined function is for the hot call site. #[inline(always)] @@ -74,7 +40,9 @@ impl<'a, 'b, T: EarlyLintPass> EarlyContextAndPass<'a, 'b, T> { fn inlined_check_id(&mut self, id: ast::NodeId) { for early_lint in self.context.buffered.take(id) { let BufferedEarlyLint { span, node_id: _, lint_id, diagnostic } = early_lint; - self.opt_span_lint_with_diagnostics(lint_id.lint, span, diagnostic); + self.context.opt_span_lint(lint_id.lint, span, |diag| { + diagnostics::decorate_lint(self.context.sess(), self.tcx, diagnostic, diag); + }); } } |
