Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ pub trait LintContext {
///
/// [`emit_lint_base`]: rustc_middle::lint::emit_lint_base#decorate-signature
#[track_caller]
fn opt_span_diag_lint<S: Into<MultiSpan>>(
fn opt_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: Option<S>,
Expand All @@ -532,13 +532,7 @@ pub trait LintContext {
span: S,
decorator: impl for<'a> Diagnostic<'a, ()>,
) {
self.opt_span_diag_lint(lint, Some(span), decorator);
}

/// Emit a lint from a lint struct (some type that implements `Diagnostic`, typically
/// generated by `#[derive(Diagnostic)]`).
fn emit_diag_lint(&self, lint: &'static Lint, decorator: impl for<'a> Diagnostic<'a, ()>) {
self.opt_span_diag_lint(lint, None as Option<Span>, decorator);
self.opt_span_lint(lint, Some(span), decorator);
}

/// This returns the lint level for the given lint at the current location.
Expand Down Expand Up @@ -594,7 +588,7 @@ impl<'tcx> LintContext for LateContext<'tcx> {
self.tcx.sess
}

fn opt_span_diag_lint<S: Into<MultiSpan>>(
fn opt_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: Option<S>,
Expand All @@ -619,13 +613,13 @@ impl LintContext for EarlyContext<'_> {
self.builder.sess()
}

fn opt_span_diag_lint<S: Into<MultiSpan>>(
fn opt_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: Option<S>,
decorator: impl for<'a> Diagnostic<'a, ()>,
) {
self.builder.opt_span_diag_lint(lint, span.map(|s| s.into()), decorator)
self.builder.opt_span_lint(lint, span.map(|s| s.into()), decorator)
}

fn get_lint_level(&self, lint: &'static Lint) -> LevelAndSource {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'ecx, 'tcx, T: EarlyLintPass> EarlyContextAndPass<'ecx, 'tcx, T> {
let BufferedEarlyLint { span, node_id: _, lint_id, diagnostic } = early_lint;
match diagnostic {
DecorateDiagCompat::Builtin(b) => {
self.context.opt_span_diag_lint(
self.context.opt_span_lint(
lint_id.lint,
span,
DecorateBuiltinLint {
Expand All @@ -50,7 +50,7 @@ impl<'ecx, 'tcx, T: EarlyLintPass> EarlyContextAndPass<'ecx, 'tcx, T> {
);
}
DecorateDiagCompat::Dynamic(d) => {
self.context.opt_span_diag_lint(lint_id.lint, span, d);
self.context.opt_span_lint(lint_id.lint, span, d);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
/// Used to emit a lint-related diagnostic based on the current state of
/// this lint context.
#[track_caller]
pub(crate) fn opt_span_diag_lint(
pub(crate) fn opt_span_lint(
&self,
lint: &'static Lint,
span: Option<MultiSpan>,
Expand Down
Loading