From c56d71f418778a6957d01f54086592b0eb38b170 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 14:29:28 +1100 Subject: [PATCH 01/11] Rename `LintContext::struct_span_lint` as `LintContext::span_lint`. --- compiler/rustc_lint/src/context.rs | 2 +- compiler/rustc_lint/src/non_fmt_panic.rs | 2 +- compiler/rustc_macros/src/diagnostics/mod.rs | 2 +- src/tools/clippy/clippy.toml | 2 +- .../src/utils/internal_lints/compiler_lint_functions.rs | 1 - src/tools/clippy/clippy_utils/src/diagnostics.rs | 8 ++++---- ...disallow_struct_span_lint.rs => disallow_span_lint.rs} | 2 +- ..._struct_span_lint.stderr => disallow_span_lint.stderr} | 6 +++--- 8 files changed, 12 insertions(+), 13 deletions(-) rename src/tools/clippy/tests/ui-internal/{disallow_struct_span_lint.rs => disallow_span_lint.rs} (92%) rename src/tools/clippy/tests/ui-internal/{disallow_struct_span_lint.stderr => disallow_span_lint.stderr} (81%) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index ffd8f1b3c79c5..dca4d14f4bf17 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -580,7 +580,7 @@ pub trait LintContext { /// /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature #[rustc_lint_diagnostics] - fn struct_span_lint>( + fn span_lint>( &self, lint: &'static Lint, span: S, diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 479acd88d7183..72074cd5af3d7 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -121,7 +121,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc } #[allow(rustc::diagnostic_outside_of_impl)] - cx.struct_span_lint(NON_FMT_PANICS, arg_span, fluent::lint_non_fmt_panic, |lint| { + cx.span_lint(NON_FMT_PANICS, arg_span, fluent::lint_non_fmt_panic, |lint| { lint.arg("name", symbol); lint.note(fluent::lint_note); lint.note(fluent::lint_more_info_note); diff --git a/compiler/rustc_macros/src/diagnostics/mod.rs b/compiler/rustc_macros/src/diagnostics/mod.rs index d3a4e7ba7d191..135b9e32fe7e6 100644 --- a/compiler/rustc_macros/src/diagnostics/mod.rs +++ b/compiler/rustc_macros/src/diagnostics/mod.rs @@ -90,7 +90,7 @@ pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream { /// Then, later, to emit the error: /// /// ```ignore (rust) -/// cx.struct_span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint { +/// cx.span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint { /// method, /// success_ordering, /// fail_ordering, diff --git a/src/tools/clippy/clippy.toml b/src/tools/clippy/clippy.toml index 4a1805f75235e..afadbb032b76a 100644 --- a/src/tools/clippy/clippy.toml +++ b/src/tools/clippy/clippy.toml @@ -2,6 +2,6 @@ avoid-breaking-exported-api = false # use the various `span_lint_*` methods instead, which also add a link to the docs disallowed-methods = [ - "rustc_lint::context::LintContext::struct_span_lint", + "rustc_lint::context::LintContext::span_lint", "rustc_middle::ty::context::TyCtxt::struct_span_lint_hir" ] diff --git a/src/tools/clippy/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs b/src/tools/clippy/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs index 5059712d69c14..df37619227c86 100644 --- a/src/tools/clippy/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs +++ b/src/tools/clippy/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs @@ -41,7 +41,6 @@ impl CompilerLintFunctions { pub fn new() -> Self { let mut map = FxHashMap::default(); map.insert("span_lint", "utils::span_lint"); - map.insert("struct_span_lint", "utils::span_lint"); map.insert("lint", "utils::span_lint"); map.insert("span_lint_note", "utils::span_lint_and_note"); map.insert("span_lint_help", "utils::span_lint_and_help"); diff --git a/src/tools/clippy/clippy_utils/src/diagnostics.rs b/src/tools/clippy/clippy_utils/src/diagnostics.rs index 7562961538e30..86a43cb367f87 100644 --- a/src/tools/clippy/clippy_utils/src/diagnostics.rs +++ b/src/tools/clippy/clippy_utils/src/diagnostics.rs @@ -47,7 +47,7 @@ fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) { /// ``` pub fn span_lint(cx: &T, lint: &'static Lint, sp: impl Into, msg: &str) { #[expect(clippy::disallowed_methods)] - cx.struct_span_lint(lint, sp, msg.to_string(), |diag| { + cx.span_lint(lint, sp, msg.to_string(), |diag| { docs_link(diag, lint); }); } @@ -81,7 +81,7 @@ pub fn span_lint_and_help( help: &str, ) { #[expect(clippy::disallowed_methods)] - cx.struct_span_lint(lint, span, msg.to_string(), |diag| { + cx.span_lint(lint, span, msg.to_string(), |diag| { let help = help.to_string(); if let Some(help_span) = help_span { diag.span_help(help_span, help.to_string()); @@ -124,7 +124,7 @@ pub fn span_lint_and_note( note: &str, ) { #[expect(clippy::disallowed_methods)] - cx.struct_span_lint(lint, span, msg.to_string(), |diag| { + cx.span_lint(lint, span, msg.to_string(), |diag| { let note = note.to_string(); if let Some(note_span) = note_span { diag.span_note(note_span, note); @@ -146,7 +146,7 @@ where F: FnOnce(&mut Diagnostic), { #[expect(clippy::disallowed_methods)] - cx.struct_span_lint(lint, sp, msg.to_string(), |diag| { + cx.span_lint(lint, sp, msg.to_string(), |diag| { f(diag); docs_link(diag, lint); }); diff --git a/src/tools/clippy/tests/ui-internal/disallow_struct_span_lint.rs b/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs similarity index 92% rename from src/tools/clippy/tests/ui-internal/disallow_struct_span_lint.rs rename to src/tools/clippy/tests/ui-internal/disallow_span_lint.rs index c81d54918cbbb..8b605b5a7e1df 100644 --- a/src/tools/clippy/tests/ui-internal/disallow_struct_span_lint.rs +++ b/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs @@ -11,7 +11,7 @@ use rustc_lint::{Lint, LintContext}; use rustc_middle::ty::TyCtxt; pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into, msg: impl Into) { - cx.struct_span_lint(lint, span, msg, |_| {}); + cx.span_lint(lint, span, msg, |_| {}); } pub fn b( diff --git a/src/tools/clippy/tests/ui-internal/disallow_struct_span_lint.stderr b/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr similarity index 81% rename from src/tools/clippy/tests/ui-internal/disallow_struct_span_lint.stderr rename to src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr index 7d424124f2b12..9b1010a1b6d24 100644 --- a/src/tools/clippy/tests/ui-internal/disallow_struct_span_lint.stderr +++ b/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr @@ -1,8 +1,8 @@ -error: use of a disallowed method `rustc_lint::context::LintContext::struct_span_lint` +error: use of a disallowed method `rustc_lint::context::LintContext::span_lint` --> $DIR/disallow_struct_span_lint.rs:14:5 | -LL | cx.struct_span_lint(lint, span, msg, |_| {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | cx.span_lint(lint, span, msg, |_| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::disallowed-methods` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]` From 2de5242ea651d57c6496c720e12fdf8b2fa6f2c1 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 14:32:02 +1100 Subject: [PATCH 02/11] Rename `LintContext::lookup` as `LintContext::opt_span_lint`. --- compiler/rustc_lint/src/context.rs | 16 ++++++++-------- compiler/rustc_middle/src/lint.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index dca4d14f4bf17..c96258b788e8e 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -541,7 +541,7 @@ pub trait LintContext { diagnostic: BuiltinLintDiagnostics, ) { // We first generate a blank diagnostic. - self.lookup(lint, span, msg, |db| { + self.opt_span_lint(lint, span, msg, |db| { // Now, set up surrounding context. diagnostics::builtin(self.sess(), diagnostic, db); // Rewrap `db`, and pass control to the user. @@ -555,7 +555,7 @@ pub trait LintContext { /// /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature #[rustc_lint_diagnostics] - fn lookup>( + fn opt_span_lint>( &self, lint: &'static Lint, span: Option, @@ -571,7 +571,7 @@ pub trait LintContext { span: S, decorator: impl for<'a> DecorateLint<'a, ()>, ) { - self.lookup(lint, Some(span), decorator.msg(), |diag| { + self.opt_span_lint(lint, Some(span), decorator.msg(), |diag| { decorator.decorate_lint(diag); }); } @@ -587,13 +587,13 @@ pub trait LintContext { msg: impl Into, decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), ) { - self.lookup(lint, Some(span), msg, decorate); + self.opt_span_lint(lint, Some(span), msg, decorate); } /// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically /// generated by `#[derive(LintDiagnostic)]`). fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a, ()>) { - self.lookup(lint, None as Option, decorator.msg(), |diag| { + self.opt_span_lint(lint, None as Option, decorator.msg(), |diag| { decorator.decorate_lint(diag); }); } @@ -608,7 +608,7 @@ pub trait LintContext { msg: impl Into, decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), ) { - self.lookup(lint, None as Option, msg, decorate); + self.opt_span_lint(lint, None as Option, msg, decorate); } /// This returns the lint level for the given lint at the current location. @@ -666,7 +666,7 @@ impl<'tcx> LintContext for LateContext<'tcx> { } #[rustc_lint_diagnostics] - fn lookup>( + fn opt_span_lint>( &self, lint: &'static Lint, span: Option, @@ -693,7 +693,7 @@ impl LintContext for EarlyContext<'_> { } #[rustc_lint_diagnostics] - fn lookup>( + fn opt_span_lint>( &self, lint: &'static Lint, span: Option, diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 4ab16cf19ba93..7f1ac0ee81530 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -251,7 +251,7 @@ pub fn explain_lint_level_source( /// - [`TyCtxt::struct_span_lint_hir`] /// - [`TyCtxt::emit_lint`] /// - [`TyCtxt::struct_lint_node`] -/// - `LintContext::lookup` +/// - `LintContext::opt_span_lint` /// /// ## `decorate` /// From c915e90f7ee79005b45fb4428784c85ac1116726 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 14:34:58 +1100 Subject: [PATCH 03/11] Rename `LintContext::lookup_with_diagnostics` as `LintContext::span_lint_with_diagnostics`. --- compiler/rustc_lint/src/builtin.rs | 2 +- compiler/rustc_lint/src/context.rs | 2 +- compiler/rustc_lint/src/early.rs | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 2ce78152cc215..113437ad1f16a 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2849,7 +2849,7 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels { let target_spans: MultiSpan = if spans.len() > 0 { spans.into() } else { (*template_span).into() }; - cx.lookup_with_diagnostics( + cx.span_lint_with_diagnostics( NAMED_ASM_LABELS, Some(target_spans), fluent::lint_builtin_asm_labels, diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index c96258b788e8e..8b063de4114e4 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -532,7 +532,7 @@ pub trait LintContext { /// /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature #[rustc_lint_diagnostics] - fn lookup_with_diagnostics( + fn span_lint_with_diagnostics( &self, lint: &'static Lint, span: Option>, diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 70af6572246f4..5ae080d470235 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -45,7 +45,13 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> { fn inlined_check_id(&mut self, id: ast::NodeId) { for early_lint in self.context.buffered.take(id) { let BufferedEarlyLint { span, msg, node_id: _, lint_id, diagnostic } = early_lint; - self.context.lookup_with_diagnostics(lint_id.lint, Some(span), msg, |_| {}, diagnostic); + self.context.span_lint_with_diagnostics( + lint_id.lint, + Some(span), + msg, + |_| {}, + diagnostic, + ); } } From 1881bfaa2b4e1f006db30aa408aaf360557ab2e9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 14:40:39 +1100 Subject: [PATCH 04/11] Rename `LintContext::emit_spanned_lint` as `LintContext::emit_span_lint`. --- compiler/rustc_lint/src/array_into_iter.rs | 2 +- compiler/rustc_lint/src/builtin.rs | 60 +++++++++---------- compiler/rustc_lint/src/context.rs | 2 +- .../src/deref_into_dyn_supertrait.rs | 2 +- .../rustc_lint/src/drop_forget_useless.rs | 10 ++-- .../src/enum_intrinsics_non_enums.rs | 8 +-- .../src/for_loops_over_fallibles.rs | 2 +- .../src/hidden_unicode_codepoints.rs | 2 +- compiler/rustc_lint/src/internal.rs | 26 ++++---- compiler/rustc_lint/src/invalid_from_utf8.rs | 2 +- compiler/rustc_lint/src/let_underscore.rs | 8 +-- compiler/rustc_lint/src/map_unit_fn.rs | 4 +- compiler/rustc_lint/src/methods.rs | 2 +- .../src/multiple_supertrait_upcastable.rs | 2 +- compiler/rustc_lint/src/non_ascii_idents.rs | 8 +-- compiler/rustc_lint/src/non_fmt_panic.rs | 4 +- compiler/rustc_lint/src/nonstandard_style.rs | 6 +- compiler/rustc_lint/src/noop_method_call.rs | 6 +- .../src/opaque_hidden_inferred_bound.rs | 2 +- compiler/rustc_lint/src/pass_by_value.rs | 2 +- compiler/rustc_lint/src/ptr_nulls.rs | 8 +-- .../rustc_lint/src/redundant_semicolon.rs | 2 +- compiler/rustc_lint/src/reference_casting.rs | 2 +- compiler/rustc_lint/src/traits.rs | 4 +- compiler/rustc_lint/src/types.rs | 40 +++++-------- compiler/rustc_lint/src/unit_bindings.rs | 2 +- compiler/rustc_lint/src/unused.rs | 22 +++---- 27 files changed, 112 insertions(+), 128 deletions(-) diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 814991cd8c971..3a5c585366a31 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -132,7 +132,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { } else { None }; - cx.emit_spanned_lint( + cx.emit_span_lint( ARRAY_INTO_ITER, call.ident.span, ArrayIntoIterDiag { target, suggestion: call.ident.span, sub }, diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 113437ad1f16a..07f127414dbc0 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -121,7 +121,7 @@ impl EarlyLintPass for WhileTrue { "{}loop", label.map_or_else(String::new, |label| format!("{}: ", label.ident,)) ); - cx.emit_spanned_lint( + cx.emit_span_lint( WHILE_TRUE, condition_span, BuiltinWhileTrue { suggestion: condition_span, replace }, @@ -162,7 +162,7 @@ impl BoxPointers { if let GenericArgKind::Type(leaf_ty) = leaf.unpack() && leaf_ty.is_box() { - cx.emit_spanned_lint(BOX_POINTERS, span, BuiltinBoxPointers { ty }); + cx.emit_span_lint(BOX_POINTERS, span, BuiltinBoxPointers { ty }); } } } @@ -265,7 +265,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns { if cx.tcx.find_field_index(ident, variant) == Some(cx.typeck_results().field_index(fieldpat.hir_id)) { - cx.emit_spanned_lint( + cx.emit_span_lint( NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span, BuiltinNonShorthandFieldPatterns { @@ -334,7 +334,7 @@ impl UnsafeCode { return; } - cx.emit_spanned_lint(UNSAFE_CODE, span, decorate); + cx.emit_span_lint(UNSAFE_CODE, span, decorate); } } @@ -509,7 +509,7 @@ impl MissingDoc { let attrs = cx.tcx.hir().attrs(cx.tcx.local_def_id_to_hir_id(def_id)); let has_doc = attrs.iter().any(has_doc); if !has_doc { - cx.emit_spanned_lint( + cx.emit_span_lint( MISSING_DOCS, cx.tcx.def_span(def_id), BuiltinMissingDoc { article, desc }, @@ -710,7 +710,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations { ) .is_ok() { - cx.emit_spanned_lint(MISSING_COPY_IMPLEMENTATIONS, item.span, BuiltinMissingCopyImpl); + cx.emit_span_lint(MISSING_COPY_IMPLEMENTATIONS, item.span, BuiltinMissingCopyImpl); } } } @@ -795,7 +795,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations { .next() .is_some(); if !has_impl { - cx.emit_spanned_lint( + cx.emit_span_lint( MISSING_DEBUG_IMPLEMENTATIONS, item.span, BuiltinMissingDebugImpl { tcx: cx.tcx, def_id: debug }, @@ -874,7 +874,7 @@ impl EarlyLintPass for AnonymousParameters { } else { ("", Applicability::HasPlaceholders) }; - cx.emit_spanned_lint( + cx.emit_span_lint( ANONYMOUS_PARAMETERS, arg.pat.span, BuiltinAnonymousParams { suggestion: (arg.pat.span, appl), ty_snip }, @@ -921,7 +921,7 @@ impl EarlyLintPass for DeprecatedAttr { BuiltinDeprecatedAttrLinkSuggestion::Default { suggestion: attr.span } } }; - cx.emit_spanned_lint( + cx.emit_span_lint( DEPRECATED, attr.span, BuiltinDeprecatedAttrLink { name, reason, link, suggestion }, @@ -931,7 +931,7 @@ impl EarlyLintPass for DeprecatedAttr { } } if attr.has_name(sym::no_start) || attr.has_name(sym::crate_id) { - cx.emit_spanned_lint( + cx.emit_span_lint( DEPRECATED, attr.span, BuiltinDeprecatedAttrUsed { @@ -973,7 +973,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: & BuiltinUnusedDocCommentSub::BlockHelp } }; - cx.emit_spanned_lint( + cx.emit_span_lint( UNUSED_DOC_COMMENTS, span, BuiltinUnusedDocComment { kind: node_kind, label: node_span, sub }, @@ -1107,7 +1107,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems { match param.kind { GenericParamKind::Lifetime { .. } => {} GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => { - cx.emit_spanned_lint( + cx.emit_span_lint( NO_MANGLE_GENERIC_ITEMS, span, BuiltinNoMangleGeneric { suggestion: no_mangle_attr.span }, @@ -1138,7 +1138,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems { // Const items do not refer to a particular location in memory, and therefore // don't have anything to attach a symbol to - cx.emit_spanned_lint( + cx.emit_span_lint( NO_MANGLE_CONST_ITEMS, it.span, BuiltinConstNoMangle { suggestion }, @@ -1201,7 +1201,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableTransmutes { get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (ty1.kind(), ty2.kind())) { if from_mutbl < to_mutbl { - cx.emit_spanned_lint(MUTABLE_TRANSMUTES, expr.span, BuiltinMutablesTransmutes); + cx.emit_span_lint(MUTABLE_TRANSMUTES, expr.span, BuiltinMutablesTransmutes); } } @@ -1270,7 +1270,7 @@ impl<'tcx> LateLintPass<'tcx> for UnstableFeatures { && let Some(items) = attr.meta_item_list() { for item in items { - cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures); + cx.emit_span_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures); } } } @@ -1323,7 +1323,7 @@ impl<'tcx> LateLintPass<'tcx> for UngatedAsyncFnTrackCaller { // Now, check if the function has the `#[track_caller]` attribute && let Some(attr) = cx.tcx.get_attr(def_id, sym::track_caller) { - cx.emit_spanned_lint( + cx.emit_span_lint( UNGATED_ASYNC_FN_TRACK_CALLER, attr.span, BuiltinUngatedAsyncFnTrackCaller { label: span, session: &cx.tcx.sess }, @@ -1389,7 +1389,7 @@ impl UnreachablePub { applicability = Applicability::MaybeIncorrect; } let def_span = cx.tcx.def_span(def_id); - cx.emit_spanned_lint( + cx.emit_span_lint( UNREACHABLE_PUB, def_span, BuiltinUnreachablePub { @@ -1518,7 +1518,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds { suggested_changing_assoc_types = true; SuggestChangingAssocTypes { ty: hir_ty } }); - cx.emit_spanned_lint( + cx.emit_span_lint( TYPE_ALIAS_BOUNDS, where_spans, BuiltinTypeAliasWhereClause { @@ -1534,7 +1534,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds { suggested_changing_assoc_types = true; SuggestChangingAssocTypes { ty: hir_ty } }); - cx.emit_spanned_lint( + cx.emit_span_lint( TYPE_ALIAS_BOUNDS, inline_spans, BuiltinTypeAliasGenericBounds { suggestion, sub }, @@ -1633,7 +1633,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints { | ClauseKind::ConstEvaluatable(..) => continue, }; if predicate.is_global() { - cx.emit_spanned_lint( + cx.emit_span_lint( TRIVIAL_BOUNDS, span, BuiltinTrivialBounds { predicate_kind_name, predicate }, @@ -1751,7 +1751,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns { replace, }); } else { - cx.emit_spanned_lint( + cx.emit_span_lint( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, BuiltinEllipsisInclusiveRangePatternsLint::Parenthesise { @@ -1769,7 +1769,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns { replace: replace.to_string(), }); } else { - cx.emit_spanned_lint( + cx.emit_span_lint( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, BuiltinEllipsisInclusiveRangePatternsLint::NonParenthesise { @@ -1895,7 +1895,7 @@ impl KeywordIdents { return; } - cx.emit_spanned_lint( + cx.emit_span_lint( KEYWORD_IDENTS, ident.span, BuiltinKeywordIdents { kw: ident, next: next_edition, suggestion: ident.span }, @@ -2203,7 +2203,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements { lint_spans.sort_unstable(); lint_spans.dedup(); - cx.emit_spanned_lint( + cx.emit_span_lint( EXPLICIT_OUTLIVES_REQUIREMENTS, lint_spans.clone(), BuiltinExplicitOutlives { @@ -2290,13 +2290,13 @@ impl EarlyLintPass for IncompleteInternalFeatures { let help = HAS_MIN_FEATURES.contains(&name).then_some(BuiltinIncompleteFeaturesHelp); - cx.emit_spanned_lint( + cx.emit_span_lint( INCOMPLETE_FEATURES, span, BuiltinIncompleteFeatures { name, note, help }, ); } else { - cx.emit_spanned_lint(INTERNAL_FEATURES, span, BuiltinInternalFeatures { name }); + cx.emit_span_lint(INTERNAL_FEATURES, span, BuiltinInternalFeatures { name }); } }); } @@ -2612,7 +2612,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { InitKind::Uninit => fluent::lint_builtin_unpermitted_type_init_uninit, }; let sub = BuiltinUnpermittedTypeInitSub { err }; - cx.emit_spanned_lint( + cx.emit_span_lint( INVALID_VALUE, expr.span, BuiltinUnpermittedTypeInit { @@ -2700,7 +2700,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr { if let rustc_hir::ExprKind::Unary(rustc_hir::UnOp::Deref, expr_deref) = expr.kind { if is_null_ptr(cx, expr_deref) { - cx.emit_spanned_lint( + cx.emit_span_lint( DEREF_NULLPTR, expr.span, BuiltinDerefNullptr { label: expr.span }, @@ -2925,12 +2925,12 @@ impl EarlyLintPass for SpecialModuleName { } match item.ident.name.as_str() { - "lib" => cx.emit_spanned_lint( + "lib" => cx.emit_span_lint( SPECIAL_MODULE_NAME, item.span, BuiltinSpecialModuleNameUsed::Lib, ), - "main" => cx.emit_spanned_lint( + "main" => cx.emit_span_lint( SPECIAL_MODULE_NAME, item.span, BuiltinSpecialModuleNameUsed::Main, diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 8b063de4114e4..bc1915f32e0f0 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -565,7 +565,7 @@ pub trait LintContext { /// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`, /// typically generated by `#[derive(LintDiagnostic)]`). - fn emit_spanned_lint>( + fn emit_span_lint>( &self, lint: &'static Lint, span: S, diff --git a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs index 98bafc0f2637e..33b5587233663 100644 --- a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs +++ b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs @@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait { .find_map(|i| (i.ident.name == sym::Target).then_some(i.span)) .map(|label| SupertraitAsDerefTargetLabel { label }); let span = tcx.def_span(item.owner_id.def_id); - cx.emit_spanned_lint( + cx.emit_span_lint( DEREF_INTO_DYN_SUPERTRAIT, span, SupertraitAsDerefTarget { diff --git a/compiler/rustc_lint/src/drop_forget_useless.rs b/compiler/rustc_lint/src/drop_forget_useless.rs index 390a1620a2a5b..9a31aa062f01a 100644 --- a/compiler/rustc_lint/src/drop_forget_useless.rs +++ b/compiler/rustc_lint/src/drop_forget_useless.rs @@ -149,28 +149,28 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr); match fn_name { sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => { - cx.emit_spanned_lint( + cx.emit_span_lint( DROPPING_REFERENCES, expr.span, DropRefDiag { arg_ty, label: arg.span }, ); } sym::mem_forget if arg_ty.is_ref() => { - cx.emit_spanned_lint( + cx.emit_span_lint( FORGETTING_REFERENCES, expr.span, ForgetRefDiag { arg_ty, label: arg.span }, ); } sym::mem_drop if is_copy && !drop_is_single_call_in_arm => { - cx.emit_spanned_lint( + cx.emit_span_lint( DROPPING_COPY_TYPES, expr.span, DropCopyDiag { arg_ty, label: arg.span }, ); } sym::mem_forget if is_copy => { - cx.emit_spanned_lint( + cx.emit_span_lint( FORGETTING_COPY_TYPES, expr.span, ForgetCopyDiag { arg_ty, label: arg.span }, @@ -180,7 +180,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { if let ty::Adt(adt, _) = arg_ty.kind() && adt.is_manually_drop() => { - cx.emit_spanned_lint( + cx.emit_span_lint( UNDROPPED_MANUALLY_DROPS, expr.span, UndroppedManuallyDropsDiag { diff --git a/compiler/rustc_lint/src/enum_intrinsics_non_enums.rs b/compiler/rustc_lint/src/enum_intrinsics_non_enums.rs index 05fe64830d17e..a67f1b62fb0d6 100644 --- a/compiler/rustc_lint/src/enum_intrinsics_non_enums.rs +++ b/compiler/rustc_lint/src/enum_intrinsics_non_enums.rs @@ -53,7 +53,7 @@ fn enforce_mem_discriminant( ) { let ty_param = cx.typeck_results().node_args(func_expr.hir_id).type_at(0); if is_non_enum(ty_param) { - cx.emit_spanned_lint( + cx.emit_span_lint( ENUM_INTRINSICS_NON_ENUMS, expr_span, EnumIntrinsicsMemDiscriminate { ty_param, note: args_span }, @@ -64,11 +64,7 @@ fn enforce_mem_discriminant( fn enforce_mem_variant_count(cx: &LateContext<'_>, func_expr: &hir::Expr<'_>, span: Span) { let ty_param = cx.typeck_results().node_args(func_expr.hir_id).type_at(0); if is_non_enum(ty_param) { - cx.emit_spanned_lint( - ENUM_INTRINSICS_NON_ENUMS, - span, - EnumIntrinsicsMemVariant { ty_param }, - ); + cx.emit_span_lint(ENUM_INTRINSICS_NON_ENUMS, span, EnumIntrinsicsMemVariant { ty_param }); } } diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs index ea922785a954b..cb7feea16b538 100644 --- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs +++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs @@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles { end_span: pat.span.between(arg.span), }; - cx.emit_spanned_lint( + cx.emit_span_lint( FOR_LOOPS_OVER_FALLIBLES, arg.span, ForLoopsOverFalliblesDiag { article, ty, sub, question_mark, suggestion }, diff --git a/compiler/rustc_lint/src/hidden_unicode_codepoints.rs b/compiler/rustc_lint/src/hidden_unicode_codepoints.rs index 7c1af6bee1dd6..054cfe92a3a48 100644 --- a/compiler/rustc_lint/src/hidden_unicode_codepoints.rs +++ b/compiler/rustc_lint/src/hidden_unicode_codepoints.rs @@ -74,7 +74,7 @@ impl HiddenUnicodeCodepoints { HiddenUnicodeCodepointsDiagSub::NoEscape { spans } }; - cx.emit_spanned_lint( + cx.emit_span_lint( TEXT_DIRECTION_CODEPOINT_IN_LITERAL, span, HiddenUnicodeCodepointsDiag { label, count, span_label: span, labels, sub }, diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index e3405aa2e5595..eb2490a47d09d 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -43,7 +43,7 @@ impl LateLintPass<'_> for DefaultHashTypes { Some(sym::HashSet) => "FxHashSet", _ => return, }; - cx.emit_spanned_lint( + cx.emit_span_lint( DEFAULT_HASH_TYPES, path.span, DefaultHashTypesDiag { preferred, used: cx.tcx.item_name(def_id) }, @@ -91,7 +91,7 @@ impl LateLintPass<'_> for QueryStability { if let Ok(Some(instance)) = ty::Instance::resolve(cx.tcx, cx.param_env, def_id, args) { let def_id = instance.def_id(); if cx.tcx.has_attr(def_id, sym::rustc_lint_query_instability) { - cx.emit_spanned_lint( + cx.emit_span_lint( POTENTIAL_QUERY_INSTABILITY, span, QueryInstability { query: cx.tcx.item_name(def_id) }, @@ -136,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind { { let span = path.span.with_hi(segment.args.map_or(segment.ident.span, |a| a.span_ext).hi()); - cx.emit_spanned_lint(USAGE_OF_TY_TYKIND, path.span, TykindKind { suggestion: span }); + cx.emit_span_lint(USAGE_OF_TY_TYKIND, path.span, TykindKind { suggestion: span }); } } @@ -186,19 +186,19 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind { match span { Some(span) => { - cx.emit_spanned_lint( + cx.emit_span_lint( USAGE_OF_TY_TYKIND, path.span, TykindKind { suggestion: span }, ); } - None => cx.emit_spanned_lint(USAGE_OF_TY_TYKIND, path.span, TykindDiag), + None => cx.emit_span_lint(USAGE_OF_TY_TYKIND, path.span, TykindDiag), } } else if !ty.span.from_expansion() && path.segments.len() > 1 && let Some(ty) = is_ty_or_ty_ctxt(cx, path) { - cx.emit_spanned_lint( + cx.emit_span_lint( USAGE_OF_QUALIFIED_TY, path.span, TyQualified { ty, suggestion: path.span }, @@ -285,7 +285,7 @@ impl EarlyLintPass for LintPassImpl { && call_site.ctxt().outer_expn_data().kind != ExpnKind::Macro(MacroKind::Bang, sym::declare_lint_pass) { - cx.emit_spanned_lint( + cx.emit_span_lint( LINT_PASS_IMPL_WITHOUT_MACRO, lint_pass.path.span, LintPassByHand, @@ -327,7 +327,7 @@ impl<'tcx> LateLintPass<'tcx> for ExistingDocKeyword { if is_doc_keyword(keyword) { return; } - cx.emit_spanned_lint( + cx.emit_span_lint( EXISTING_DOC_KEYWORD, attr.span, NonExistentDocKeyword { keyword }, @@ -405,7 +405,7 @@ impl LateLintPass<'_> for Diagnostics { } debug!(?found_impl); if !found_parent_with_attr && !found_impl { - cx.emit_spanned_lint(DIAGNOSTIC_OUTSIDE_OF_IMPL, span, DiagOutOfImpl); + cx.emit_span_lint(DIAGNOSTIC_OUTSIDE_OF_IMPL, span, DiagOutOfImpl); } let mut found_diagnostic_message = false; @@ -421,7 +421,7 @@ impl LateLintPass<'_> for Diagnostics { } debug!(?found_diagnostic_message); if !found_parent_with_attr && !found_diagnostic_message { - cx.emit_spanned_lint(UNTRANSLATABLE_DIAGNOSTIC, span, UntranslatableDiag); + cx.emit_span_lint(UNTRANSLATABLE_DIAGNOSTIC, span, UntranslatableDiag); } } } @@ -490,7 +490,7 @@ impl EarlyLintPass for Diagnostics { }) { return; } - cx.emit_spanned_lint( + cx.emit_span_lint( UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL, stmt.span, UntranslatableDiagnosticTrivial, @@ -528,7 +528,7 @@ impl LateLintPass<'_> for BadOptAccess { && let Some(lit) = item.lit() && let ast::LitKind::Str(val, _) = lit.kind { - cx.emit_spanned_lint( + cx.emit_span_lint( BAD_OPT_ACCESS, expr.span, BadOptAccessDiag { msg: val.as_str() }, @@ -553,7 +553,7 @@ impl<'tcx> LateLintPass<'tcx> for SpanUseEqCtxt { expr.kind { if is_span_ctxt_call(cx, lhs) && is_span_ctxt_call(cx, rhs) { - cx.emit_spanned_lint(SPAN_USE_EQ_CTXT, expr.span, SpanUseEqCtxtDiag); + cx.emit_span_lint(SPAN_USE_EQ_CTXT, expr.span, SpanUseEqCtxtDiag); } } } diff --git a/compiler/rustc_lint/src/invalid_from_utf8.rs b/compiler/rustc_lint/src/invalid_from_utf8.rs index 2b345f62a95d5..081e3e875302b 100644 --- a/compiler/rustc_lint/src/invalid_from_utf8.rs +++ b/compiler/rustc_lint/src/invalid_from_utf8.rs @@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidFromUtf8 { let valid_up_to = utf8_error.valid_up_to(); let is_unchecked_variant = diag_item.as_str().contains("unchecked"); - cx.emit_spanned_lint( + cx.emit_span_lint( if is_unchecked_variant { INVALID_FROM_UTF8_UNCHECKED } else { diff --git a/compiler/rustc_lint/src/let_underscore.rs b/compiler/rustc_lint/src/let_underscore.rs index 0c9dff2b5d93e..c552b9832553a 100644 --- a/compiler/rustc_lint/src/let_underscore.rs +++ b/compiler/rustc_lint/src/let_underscore.rs @@ -160,14 +160,10 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { pat.span, "this lock is not assigned to a binding and is immediately dropped".to_string(), ); - cx.emit_spanned_lint(LET_UNDERSCORE_LOCK, span, NonBindingLet::SyncLock { sub }); + cx.emit_span_lint(LET_UNDERSCORE_LOCK, span, NonBindingLet::SyncLock { sub }); // Only emit let_underscore_drop for top-level `_` patterns. } else if can_use_init.is_some() { - cx.emit_spanned_lint( - LET_UNDERSCORE_DROP, - local.span, - NonBindingLet::DropType { sub }, - ); + cx.emit_span_lint(LET_UNDERSCORE_DROP, local.span, NonBindingLet::DropType { sub }); } }); } diff --git a/compiler/rustc_lint/src/map_unit_fn.rs b/compiler/rustc_lint/src/map_unit_fn.rs index 7c692fee33389..07980cfb6fa0f 100644 --- a/compiler/rustc_lint/src/map_unit_fn.rs +++ b/compiler/rustc_lint/src/map_unit_fn.rs @@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for MapUnitFn { let fn_ty = cx.tcx.fn_sig(id).skip_binder(); let ret_ty = fn_ty.output().skip_binder(); if is_unit_type(ret_ty) { - cx.emit_spanned_lint( + cx.emit_span_lint( MAP_UNIT_FN, span, MappingToUnit { @@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for MapUnitFn { let cl_ty = subs.as_closure().sig(); let ret_ty = cl_ty.output().skip_binder(); if is_unit_type(ret_ty) { - cx.emit_spanned_lint( + cx.emit_span_lint( MAP_UNIT_FN, span, MappingToUnit { diff --git a/compiler/rustc_lint/src/methods.rs b/compiler/rustc_lint/src/methods.rs index 5b63b19c53c8a..9cfdaf0ce2ff6 100644 --- a/compiler/rustc_lint/src/methods.rs +++ b/compiler/rustc_lint/src/methods.rs @@ -57,7 +57,7 @@ fn lint_cstring_as_ptr( if cx.tcx.is_diagnostic_item(sym::Result, def.did()) { if let ty::Adt(adt, _) = args.type_at(0).kind() { if cx.tcx.is_diagnostic_item(sym::cstring_type, adt.did()) { - cx.emit_spanned_lint( + cx.emit_span_lint( TEMPORARY_CSTRING_AS_PTR, as_ptr_span, CStringPtr { as_ptr: as_ptr_span, unwrap: unwrap.span }, diff --git a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs index dfefaf82fd7da..69d623b547b58 100644 --- a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs +++ b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs @@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable { .into_iter() .filter_map(|(pred, _)| pred.as_trait_clause()); if direct_super_traits_iter.count() > 1 { - cx.emit_spanned_lint( + cx.emit_span_lint( MULTIPLE_SUPERTRAIT_UPCASTABLE, cx.tcx.def_span(def_id), crate::lints::MultipleSupertraitUpcastable { ident: item.ident }, diff --git a/compiler/rustc_lint/src/non_ascii_idents.rs b/compiler/rustc_lint/src/non_ascii_idents.rs index 3405dd3a9169c..00f87a5af80fc 100644 --- a/compiler/rustc_lint/src/non_ascii_idents.rs +++ b/compiler/rustc_lint/src/non_ascii_idents.rs @@ -186,11 +186,11 @@ impl EarlyLintPass for NonAsciiIdents { continue; } has_non_ascii_idents = true; - cx.emit_spanned_lint(NON_ASCII_IDENTS, sp, IdentifierNonAsciiChar); + cx.emit_span_lint(NON_ASCII_IDENTS, sp, IdentifierNonAsciiChar); if check_uncommon_codepoints && !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed) { - cx.emit_spanned_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints); + cx.emit_span_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints); } } @@ -218,7 +218,7 @@ impl EarlyLintPass for NonAsciiIdents { .entry(skeleton_sym) .and_modify(|(existing_symbol, existing_span, existing_is_ascii)| { if !*existing_is_ascii || !is_ascii { - cx.emit_spanned_lint( + cx.emit_span_lint( CONFUSABLE_IDENTS, sp, ConfusableIdentifierPair { @@ -339,7 +339,7 @@ impl EarlyLintPass for NonAsciiIdents { let char_info = format!("'{}' (U+{:04X})", ch, ch as u32); includes += &char_info; } - cx.emit_spanned_lint( + cx.emit_span_lint( MIXED_SCRIPT_CONFUSABLES, sp, MixedScriptConfusables { set: script_set.to_string(), includes }, diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 72074cd5af3d7..ebef77f687972 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -251,7 +251,7 @@ fn check_panic_str<'tcx>( .map(|span| fmt_span.from_inner(InnerSpan::new(span.start, span.end))) .collect(), }; - cx.emit_spanned_lint( + cx.emit_span_lint( NON_FMT_PANICS, arg_spans, NonFmtPanicUnused { @@ -268,7 +268,7 @@ fn check_panic_str<'tcx>( .collect() }); let count = brace_spans.as_ref().map(|v| v.len()).unwrap_or(/* any number >1 */ 2); - cx.emit_spanned_lint( + cx.emit_span_lint( NON_FMT_PANICS, brace_spans.unwrap_or_else(|| vec![span]), NonFmtPanicBraces { diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 59f27a88aec63..05b39829a12f1 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -150,7 +150,7 @@ impl NonCamelCaseTypes { } else { NonCamelCaseTypeSub::Label { span: ident.span } }; - cx.emit_spanned_lint( + cx.emit_span_lint( NON_CAMEL_CASE_TYPES, ident.span, NonCamelCaseType { sort, name, sub }, @@ -320,7 +320,7 @@ impl NonSnakeCase { } else { NonSnakeCaseDiagSub::Label { span } }; - cx.emit_spanned_lint(NON_SNAKE_CASE, span, NonSnakeCaseDiag { sort, name, sc, sub }); + cx.emit_span_lint(NON_SNAKE_CASE, span, NonSnakeCaseDiag { sort, name, sc, sub }); } } } @@ -481,7 +481,7 @@ impl NonUpperCaseGlobals { } else { NonUpperCaseGlobalSub::Label { span: ident.span } }; - cx.emit_spanned_lint( + cx.emit_span_lint( NON_UPPER_CASE_GLOBALS, ident.span, NonUpperCaseGlobal { sort, name, sub }, diff --git a/compiler/rustc_lint/src/noop_method_call.rs b/compiler/rustc_lint/src/noop_method_call.rs index cfbca6efbfa54..26c5e4fb4837d 100644 --- a/compiler/rustc_lint/src/noop_method_call.rs +++ b/compiler/rustc_lint/src/noop_method_call.rs @@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall { let orig_ty = expr_ty.peel_refs(); if receiver_ty == expr_ty { - cx.emit_spanned_lint( + cx.emit_span_lint( NOOP_METHOD_CALL, span, NoopMethodCallDiag { method: call.ident.name, orig_ty, trait_, label: span }, @@ -131,12 +131,12 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall { // If `type_of(x) == T` and `x.borrow()` is used to get `&T`, // then that should be allowed sym::noop_method_borrow => return, - sym::noop_method_clone => cx.emit_spanned_lint( + sym::noop_method_clone => cx.emit_span_lint( SUSPICIOUS_DOUBLE_REF_OP, span, SuspiciousDoubleRefCloneDiag { ty: expr_ty }, ), - sym::noop_method_deref => cx.emit_spanned_lint( + sym::noop_method_deref => cx.emit_span_lint( SUSPICIOUS_DOUBLE_REF_OP, span, SuspiciousDoubleRefDerefDiag { ty: expr_ty }, diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index 44b23b8bdc0c3..f64509fe8bc67 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { }), _ => None, }; - cx.emit_spanned_lint( + cx.emit_span_lint( OPAQUE_HIDDEN_INFERRED_BOUND, pred_span, OpaqueHiddenInferredBoundLint { diff --git a/compiler/rustc_lint/src/pass_by_value.rs b/compiler/rustc_lint/src/pass_by_value.rs index fce750c9b558f..160d42caa9e2a 100644 --- a/compiler/rustc_lint/src/pass_by_value.rs +++ b/compiler/rustc_lint/src/pass_by_value.rs @@ -29,7 +29,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue { } } if let Some(t) = path_for_pass_by_value(cx, inner_ty) { - cx.emit_spanned_lint( + cx.emit_span_lint( PASS_BY_VALUE, ty.span, PassByValueDiag { ty: t, suggestion: ty.span }, diff --git a/compiler/rustc_lint/src/ptr_nulls.rs b/compiler/rustc_lint/src/ptr_nulls.rs index 4ac8a5ceb8553..8038115ef51c1 100644 --- a/compiler/rustc_lint/src/ptr_nulls.rs +++ b/compiler/rustc_lint/src/ptr_nulls.rs @@ -97,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for PtrNullChecks { ) && let Some(diag) = incorrect_check(cx, arg) => { - cx.emit_spanned_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag) + cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag) } // Catching: @@ -110,7 +110,7 @@ impl<'tcx> LateLintPass<'tcx> for PtrNullChecks { ) && let Some(diag) = incorrect_check(cx, receiver) => { - cx.emit_spanned_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag) + cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag) } ExprKind::Binary(op, left, right) if matches!(op.node, BinOpKind::Eq) => { @@ -134,7 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for PtrNullChecks { && let LitKind::Int(v, _) = spanned.node && v == 0 => { - cx.emit_spanned_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag) + cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag) } // Catching: @@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for PtrNullChecks { && let Some(diag_item) = cx.tcx.get_diagnostic_name(def_id) && (diag_item == sym::ptr_null || diag_item == sym::ptr_null_mut) => { - cx.emit_spanned_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag) + cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag) } _ => {} diff --git a/compiler/rustc_lint/src/redundant_semicolon.rs b/compiler/rustc_lint/src/redundant_semicolon.rs index 9a8b14b4907ea..1681ac2f1e5a4 100644 --- a/compiler/rustc_lint/src/redundant_semicolon.rs +++ b/compiler/rustc_lint/src/redundant_semicolon.rs @@ -47,7 +47,7 @@ fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, boo return; } - cx.emit_spanned_lint( + cx.emit_span_lint( REDUNDANT_SEMICOLONS, span, RedundantSemicolonsDiag { multiple, suggestion: span }, diff --git a/compiler/rustc_lint/src/reference_casting.rs b/compiler/rustc_lint/src/reference_casting.rs index 96290288f072c..9e6cca8531784 100644 --- a/compiler/rustc_lint/src/reference_casting.rs +++ b/compiler/rustc_lint/src/reference_casting.rs @@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidReferenceCasting { let orig_cast = if init.span != e.span { Some(init.span) } else { None }; let ty_has_interior_mutability = ty_has_interior_mutability.then_some(()); - cx.emit_spanned_lint( + cx.emit_span_lint( INVALID_REFERENCE_CASTING, expr.span, if pat == PatternKind::Assign { diff --git a/compiler/rustc_lint/src/traits.rs b/compiler/rustc_lint/src/traits.rs index e812493b3dd39..789f154eac5bc 100644 --- a/compiler/rustc_lint/src/traits.rs +++ b/compiler/rustc_lint/src/traits.rs @@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints { continue; } let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return }; - cx.emit_spanned_lint( + cx.emit_span_lint( DROP_BOUNDS, span, DropTraitConstraintsDiag { predicate, tcx: cx.tcx, def_id }, @@ -116,7 +116,7 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints { let def_id = bound.trait_ref.trait_def_id(); if cx.tcx.lang_items().drop_trait() == def_id { let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return }; - cx.emit_spanned_lint(DYN_DROP, bound.span, DropGlue { tcx: cx.tcx, def_id }); + cx.emit_span_lint(DYN_DROP, bound.span, DropGlue { tcx: cx.tcx, def_id }); } } } diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 28faea58528ca..e3d3150b36ef4 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -254,7 +254,7 @@ fn lint_overflowing_range_endpoint<'tcx>( } }; - cx.emit_spanned_lint( + cx.emit_span_lint( OVERFLOWING_LITERALS, struct_expr.span, RangeEndpointOutOfRange { ty, sub: sub_sugg }, @@ -371,7 +371,7 @@ fn report_bin_hex_error( }) .flatten(); - cx.emit_spanned_lint( + cx.emit_span_lint( OVERFLOWING_LITERALS, expr.span, OverflowingBinHex { @@ -473,7 +473,7 @@ fn lint_int_literal<'tcx>( let help = get_type_suggestion(cx.typeck_results().node_type(e.hir_id), v, negative) .map(|suggestion_ty| OverflowingIntHelp { suggestion_ty }); - cx.emit_spanned_lint( + cx.emit_span_lint( OVERFLOWING_LITERALS, span, OverflowingInt { ty: t.name_str(), lit, min, max, help }, @@ -501,7 +501,7 @@ fn lint_uint_literal<'tcx>( match par_e.kind { hir::ExprKind::Cast(..) => { if let ty::Char = cx.typeck_results().expr_ty(par_e).kind() { - cx.emit_spanned_lint( + cx.emit_span_lint( OVERFLOWING_LITERALS, par_e.span, OnlyCastu8ToChar { span: par_e.span, literal: lit_val }, @@ -528,7 +528,7 @@ fn lint_uint_literal<'tcx>( ); return; } - cx.emit_spanned_lint( + cx.emit_span_lint( OVERFLOWING_LITERALS, e.span, OverflowingUInt { @@ -570,7 +570,7 @@ fn lint_literal<'tcx>( _ => bug!(), }; if is_infinite == Ok(true) { - cx.emit_spanned_lint( + cx.emit_span_lint( OVERFLOWING_LITERALS, e.span, OverflowingLiteral { @@ -654,7 +654,7 @@ fn lint_nan<'tcx>( _ => return, }; - cx.emit_spanned_lint(INVALID_NAN_COMPARISONS, e.span, lint); + cx.emit_span_lint(INVALID_NAN_COMPARISONS, e.span, lint); } fn lint_wide_pointer<'tcx>( @@ -700,7 +700,7 @@ fn lint_wide_pointer<'tcx>( let (Some(l_span), Some(r_span)) = (l.span.find_ancestor_inside(e.span), r.span.find_ancestor_inside(e.span)) else { - return cx.emit_spanned_lint( + return cx.emit_span_lint( AMBIGUOUS_WIDE_POINTER_COMPARISONS, e.span, AmbiguousWidePointerComparisons::Spanless, @@ -718,7 +718,7 @@ fn lint_wide_pointer<'tcx>( let deref_left = &*"*".repeat(l_ty_refs); let deref_right = &*"*".repeat(r_ty_refs); - cx.emit_spanned_lint( + cx.emit_span_lint( AMBIGUOUS_WIDE_POINTER_COMPARISONS, e.span, AmbiguousWidePointerComparisons::Spanful { @@ -770,7 +770,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { hir::ExprKind::Binary(binop, ref l, ref r) => { if is_comparison(binop) { if !check_limits(cx, binop, l, r) { - cx.emit_spanned_lint(UNUSED_COMPARISONS, e.span, UnusedComparisons); + cx.emit_span_lint(UNUSED_COMPARISONS, e.span, UnusedComparisons); } else { lint_nan(cx, e, binop, l, r); lint_wide_pointer(cx, e, binop.node, l, r); @@ -1464,7 +1464,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } else { None }; - self.cx.emit_spanned_lint( + self.cx.emit_span_lint( lint, sp, ImproperCTypes { ty, desc, label: sp, help, note, span_note }, @@ -1792,7 +1792,7 @@ impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences { // We only warn if the largest variant is at least thrice as large as // the second-largest. if largest > slargest * 3 && slargest > 0 { - cx.emit_spanned_lint( + cx.emit_span_lint( VARIANT_SIZE_DIFFERENCES, enum_definition.variants[largest_index].span, VariantSizeDifferencesDiag { largest }, @@ -1913,17 +1913,9 @@ impl InvalidAtomicOrdering { && (ordering == invalid_ordering || ordering == sym::AcqRel) { if method == sym::load { - cx.emit_spanned_lint( - INVALID_ATOMIC_ORDERING, - ordering_arg.span, - AtomicOrderingLoad, - ); + cx.emit_span_lint(INVALID_ATOMIC_ORDERING, ordering_arg.span, AtomicOrderingLoad); } else { - cx.emit_spanned_lint( - INVALID_ATOMIC_ORDERING, - ordering_arg.span, - AtomicOrderingStore, - ); + cx.emit_span_lint(INVALID_ATOMIC_ORDERING, ordering_arg.span, AtomicOrderingStore); }; } } @@ -1935,7 +1927,7 @@ impl InvalidAtomicOrdering { && matches!(cx.tcx.get_diagnostic_name(def_id), Some(sym::fence | sym::compiler_fence)) && Self::match_ordering(cx, &args[0]) == Some(sym::Relaxed) { - cx.emit_spanned_lint(INVALID_ATOMIC_ORDERING, args[0].span, AtomicOrderingFence); + cx.emit_span_lint(INVALID_ATOMIC_ORDERING, args[0].span, AtomicOrderingFence); } } @@ -1957,7 +1949,7 @@ impl InvalidAtomicOrdering { let Some(fail_ordering) = Self::match_ordering(cx, fail_order_arg) else { return }; if matches!(fail_ordering, sym::Release | sym::AcqRel) { - cx.emit_spanned_lint( + cx.emit_span_lint( INVALID_ATOMIC_ORDERING, fail_order_arg.span, InvalidAtomicOrderingDiag { method, fail_order_arg_span: fail_order_arg.span }, diff --git a/compiler/rustc_lint/src/unit_bindings.rs b/compiler/rustc_lint/src/unit_bindings.rs index c80889f3ae752..b74430d8fa09c 100644 --- a/compiler/rustc_lint/src/unit_bindings.rs +++ b/compiler/rustc_lint/src/unit_bindings.rs @@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for UnitBindings { && !matches!(init.kind, hir::ExprKind::Tup([])) && !matches!(local.pat.kind, hir::PatKind::Tuple([], ..)) { - cx.emit_spanned_lint( + cx.emit_span_lint( UNIT_BINDINGS, local.span, UnitBindingsDiag { label: local.pat.span }, diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 39decf1faabf1..ea3747dfac4b3 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -182,7 +182,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { let mut op_warned = false; if let Some(must_use_op) = must_use_op { - cx.emit_spanned_lint( + cx.emit_span_lint( UNUSED_MUST_USE, expr.span, UnusedOp { @@ -202,7 +202,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { } if !(type_lint_emitted_or_suppressed || fn_warned || op_warned) { - cx.emit_spanned_lint(UNUSED_RESULTS, s.span, UnusedResult { ty }); + cx.emit_span_lint(UNUSED_RESULTS, s.span, UnusedResult { ty }); } fn check_fn_must_use( @@ -494,21 +494,21 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { ); } MustUsePath::Closure(span) => { - cx.emit_spanned_lint( + cx.emit_span_lint( UNUSED_MUST_USE, *span, UnusedClosure { count: plural_len, pre: descr_pre, post: descr_post }, ); } MustUsePath::Coroutine(span) => { - cx.emit_spanned_lint( + cx.emit_span_lint( UNUSED_MUST_USE, *span, UnusedCoroutine { count: plural_len, pre: descr_pre, post: descr_post }, ); } MustUsePath::Def(span, def_id, reason) => { - cx.emit_spanned_lint( + cx.emit_span_lint( UNUSED_MUST_USE, *span, UnusedDef { @@ -568,9 +568,9 @@ impl<'tcx> LateLintPass<'tcx> for PathStatements { } else { PathStatementDropSub::Help { span: s.span } }; - cx.emit_spanned_lint(PATH_STATEMENTS, s.span, PathStatementDrop { sub }) + cx.emit_span_lint(PATH_STATEMENTS, s.span, PathStatementDrop { sub }) } else { - cx.emit_spanned_lint(PATH_STATEMENTS, s.span, PathStatementNoEffect); + cx.emit_span_lint(PATH_STATEMENTS, s.span, PathStatementNoEffect); } } } @@ -824,7 +824,7 @@ trait UnusedDelimLint { end_replace: hi_replace, } }); - cx.emit_spanned_lint( + cx.emit_span_lint( self.lint(), primary_span, UnusedDelim { delim: Self::DELIM_STR, item: msg, suggestion }, @@ -1507,7 +1507,7 @@ impl UnusedImportBraces { ast::UseTreeKind::Nested(_) => return, }; - cx.emit_spanned_lint( + cx.emit_span_lint( UNUSED_IMPORT_BRACES, item.span, UnusedImportBracesDiag { node: node_name }, @@ -1564,10 +1564,10 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAllocation { if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind { match m { adjustment::AutoBorrowMutability::Not => { - cx.emit_spanned_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationDiag); + cx.emit_span_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationDiag); } adjustment::AutoBorrowMutability::Mut { .. } => { - cx.emit_spanned_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationMutDiag); + cx.emit_span_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationMutDiag); } }; } From 749afe20507fd9052af4301f073b6d0c0ab852c0 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 15:27:11 +1100 Subject: [PATCH 05/11] Rename `LintLevelsBuilder::struct_lint` as `LintLevelsBuilder::opt_span_lint`. --- compiler/rustc_lint/src/context.rs | 2 +- compiler/rustc_lint/src/levels.rs | 2 +- compiler/rustc_trait_selection/src/traits/specialize/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index bc1915f32e0f0..cc23a553b1617 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -700,7 +700,7 @@ impl LintContext for EarlyContext<'_> { msg: impl Into, decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), ) { - self.builder.struct_lint(lint, span.map(|s| s.into()), msg, decorate) + self.builder.opt_span_lint(lint, span.map(|s| s.into()), msg, decorate) } fn get_lint_level(&self, lint: &'static Lint) -> Level { diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index b98b1a2935c04..db80c1024dd1a 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -1099,7 +1099,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature #[rustc_lint_diagnostics] #[track_caller] - pub(crate) fn struct_lint( + pub(crate) fn opt_span_lint( &self, lint: &'static Lint, span: Option, diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index b37d9714ddd8c..910fc0ee31463 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -387,7 +387,7 @@ fn report_conflicting_impls<'tcx>( let impl_span = tcx.def_span(impl_def_id); // Work to be done after we've built the DiagnosticBuilder. We have to define it - // now because the struct_lint methods don't return back the DiagnosticBuilder + // now because the lint emit methods don't return back the DiagnosticBuilder // that's passed in. fn decorate<'tcx>( tcx: TyCtxt<'tcx>, From 36e65146060b095e7491fcd03966f09c83f69ae7 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 15:37:29 +1100 Subject: [PATCH 06/11] Rename `LintLevelsBuilder::emit_spanned_lint` as `LintLevelsBuilder::emit_span_lint`. --- compiler/rustc_lint/src/levels.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index db80c1024dd1a..41b6245ae0d1e 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -682,7 +682,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { sub, }); } else { - self.emit_spanned_lint( + self.emit_span_lint( FORBIDDEN_LINT_GROUPS, src.span().into(), OverruledAttributeLint { @@ -925,7 +925,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { } Err((Some(ids), ref new_lint_name)) => { let lint = builtin::RENAMED_AND_REMOVED_LINTS; - self.emit_spanned_lint( + self.emit_span_lint( lint, sp.into(), DeprecatedLintName { @@ -976,13 +976,13 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { RenamedLintSuggestion::WithSpan { suggestion: sp, replace }; let name = tool_ident.map(|tool| format!("{tool}::{name}")).unwrap_or(name); let lint = RenamedLint { name: name.as_str(), suggestion }; - self.emit_spanned_lint(RENAMED_AND_REMOVED_LINTS, sp.into(), lint); + self.emit_span_lint(RENAMED_AND_REMOVED_LINTS, sp.into(), lint); } CheckLintNameResult::Removed(ref reason) => { let name = tool_ident.map(|tool| format!("{tool}::{name}")).unwrap_or(name); let lint = RemovedLint { name: name.as_str(), reason }; - self.emit_spanned_lint(RENAMED_AND_REMOVED_LINTS, sp.into(), lint); + self.emit_span_lint(RENAMED_AND_REMOVED_LINTS, sp.into(), lint); } CheckLintNameResult::NoLint(suggestion) => { @@ -995,7 +995,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { UnknownLintSuggestion::WithSpan { suggestion: sp, replace, from_rustc } }); let lint = UnknownLint { name, suggestion }; - self.emit_spanned_lint(UNKNOWN_LINTS, sp.into(), lint); + self.emit_span_lint(UNKNOWN_LINTS, sp.into(), lint); } } // If this lint was renamed, apply the new lint instead of ignoring the attribute. @@ -1041,7 +1041,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { continue; }; - self.emit_spanned_lint( + self.emit_span_lint( UNUSED_ATTRIBUTES, lint_attr_span.into(), IgnoredUnlessCrateSpecified { level: level.as_str(), name: lint_attr_name }, @@ -1111,7 +1111,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { } #[track_caller] - pub fn emit_spanned_lint( + pub fn emit_span_lint( &self, lint: &'static Lint, span: MultiSpan, From 681b9aa363d350a4b8ecb9eedc025baa6e0bf9ca Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 15:49:28 +1100 Subject: [PATCH 07/11] Rename `TyCtxt::struct_lint_node` as `TyCtxt::node_lint`. --- compiler/rustc_lint/src/context.rs | 2 +- compiler/rustc_middle/src/lint.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 4 ++-- src/librustdoc/core.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index cc23a553b1617..5c34b763e5d50 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -677,7 +677,7 @@ impl<'tcx> LintContext for LateContext<'tcx> { match span { Some(s) => self.tcx.struct_span_lint_hir(lint, hir_id, s, msg, decorate), - None => self.tcx.struct_lint_node(lint, hir_id, msg, decorate), + None => self.tcx.node_lint(lint, hir_id, msg, decorate), } } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 7f1ac0ee81530..70506313832b4 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -250,7 +250,7 @@ pub fn explain_lint_level_source( /// - [`TyCtxt::emit_spanned_lint`] /// - [`TyCtxt::struct_span_lint_hir`] /// - [`TyCtxt::emit_lint`] -/// - [`TyCtxt::struct_lint_node`] +/// - [`TyCtxt::node_lint`] /// - `LintContext::opt_span_lint` /// /// ## `decorate` diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index e65e10603702a..9d55c74d54b91 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2117,7 +2117,7 @@ impl<'tcx> TyCtxt<'tcx> { id: HirId, decorator: impl for<'a> DecorateLint<'a, ()>, ) { - self.struct_lint_node(lint, id, decorator.msg(), |diag| { + self.node_lint(lint, id, decorator.msg(), |diag| { decorator.decorate_lint(diag); }) } @@ -2127,7 +2127,7 @@ impl<'tcx> TyCtxt<'tcx> { /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_lint_node( + pub fn node_lint( self, lint: &'static Lint, id: HirId, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 8bb1ed6d476d4..7cf385de6b77e 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -377,7 +377,7 @@ pub(crate) fn run_global_ctxt( {}/rustdoc/how-to-write-documentation.html", crate::DOC_RUST_LANG_ORG_CHANNEL ); - tcx.struct_lint_node( + tcx.node_lint( crate::lint::MISSING_CRATE_LEVEL_DOCS, DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(), "no documentation found for this crate's top-level module", From cfdea760f5ca36fdd04c8f18f3dac0bef66055cc Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 16:14:33 +1100 Subject: [PATCH 08/11] Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`. --- .../rustc_codegen_ssa/src/codegen_attrs.rs | 2 +- .../src/astconv/generics.rs | 2 +- .../rustc_hir_analysis/src/astconv/lint.rs | 30 ++++++++----------- .../rustc_hir_analysis/src/astconv/mod.rs | 2 +- .../rustc_hir_analysis/src/check/check.rs | 6 ++-- .../src/check/intrinsicck.rs | 2 +- .../rustc_hir_analysis/src/check_unused.rs | 8 +---- .../src/coherence/orphan.rs | 2 +- .../src/collect/generics_of.rs | 2 +- .../src/collect/resolve_bound_vars.rs | 2 +- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- .../src/method/prelude2021.rs | 6 ++-- compiler/rustc_hir_typeck/src/method/probe.rs | 4 +-- compiler/rustc_hir_typeck/src/pat.rs | 2 +- compiler/rustc_hir_typeck/src/upvar.rs | 2 +- compiler/rustc_lint/src/context.rs | 2 +- compiler/rustc_middle/src/lint.rs | 2 +- compiler/rustc_middle/src/middle/stability.rs | 4 +-- .../rustc_middle/src/mir/interpret/queries.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 2 +- .../src/traits/object_safety.rs | 2 +- .../src/traits/specialize/mod.rs | 2 +- src/librustdoc/html/markdown.rs | 4 +-- .../passes/check_doc_test_visibility.rs | 4 +-- .../passes/collect_intra_doc_links.rs | 2 +- src/librustdoc/passes/lint/bare_urls.rs | 2 +- .../passes/lint/check_code_block_syntax.rs | 2 +- src/librustdoc/passes/lint/html_tags.rs | 2 +- .../passes/lint/redundant_explicit_links.rs | 4 +-- .../passes/lint/unescaped_backticks.rs | 2 +- src/tools/clippy/clippy.toml | 2 +- .../clippy/clippy_utils/src/diagnostics.rs | 4 +-- .../tests/ui-internal/disallow_span_lint.rs | 2 +- .../ui-internal/disallow_span_lint.stderr | 4 +-- 34 files changed, 56 insertions(+), 68 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 299d6f984207f..cca239a43b342 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -563,7 +563,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { if codegen_fn_attrs.inline == InlineAttr::Always { if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) { let hir_id = tcx.local_def_id_to_hir_id(did); - tcx.struct_span_lint_hir( + tcx.node_span_lint( lint::builtin::INLINE_NO_SANITIZE, hir_id, no_sanitize_span, diff --git a/compiler/rustc_hir_analysis/src/astconv/generics.rs b/compiler/rustc_hir_analysis/src/astconv/generics.rs index f9628d1d6f3ef..4284758b1172e 100644 --- a/compiler/rustc_hir_analysis/src/astconv/generics.rs +++ b/compiler/rustc_hir_analysis/src/astconv/generics.rs @@ -656,7 +656,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes( } else { let mut multispan = MultiSpan::from_span(span); multispan.push_span_label(span_late, note); - tcx.struct_span_lint_hir( + tcx.node_span_lint( LATE_BOUND_LIFETIME_ARGUMENTS, args.args[0].hir_id(), multispan, diff --git a/compiler/rustc_hir_analysis/src/astconv/lint.rs b/compiler/rustc_hir_analysis/src/astconv/lint.rs index 27dc088d5dd8c..33e782abc68ed 100644 --- a/compiler/rustc_hir_analysis/src/astconv/lint.rs +++ b/compiler/rustc_hir_analysis/src/astconv/lint.rs @@ -240,24 +240,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { diag.stash(self_ty.span, StashKey::TraitMissingMethod); } else { let msg = "trait objects without an explicit `dyn` are deprecated"; - tcx.struct_span_lint_hir( - BARE_TRAIT_OBJECTS, - self_ty.hir_id, - self_ty.span, - msg, - |lint| { - if self_ty.span.can_be_used_for_suggestions() - && !self.maybe_lint_impl_trait(self_ty, lint) - { - lint.multipart_suggestion_verbose( - "use `dyn`", - sugg, - Applicability::MachineApplicable, - ); - } - self.maybe_lint_blanket_trait_impl(self_ty, lint); - }, - ); + tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| { + if self_ty.span.can_be_used_for_suggestions() + && !self.maybe_lint_impl_trait(self_ty, lint) + { + lint.multipart_suggestion_verbose( + "use `dyn`", + sugg, + Applicability::MachineApplicable, + ); + } + self.maybe_lint_blanket_trait_impl(self_ty, lint); + }); } } } diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 00f0d6e7c2241..7c97c2a1a6ff2 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -1394,7 +1394,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let ty = self.projected_ty_from_poly_trait_ref(span, assoc_ty_did, assoc_segment, bound); if let Some(variant_def_id) = variant_resolution { - tcx.struct_span_lint_hir( + tcx.node_span_lint( AMBIGUOUS_ASSOCIATED_ITEMS, hir_ref_id, span, diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 03e2b0e00220e..c63bafcdcd464 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -46,7 +46,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) { .emit(); } None => { - tcx.struct_span_lint_hir( + tcx.node_span_lint( UNSUPPORTED_CALLING_CONVENTIONS, hir_id, span, @@ -183,7 +183,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) { } }; if layout.abi.is_uninhabited() { - tcx.struct_span_lint_hir( + tcx.node_span_lint( UNINHABITED_STATIC, tcx.local_def_id_to_hir_id(def_id), span, @@ -1079,7 +1079,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) // If there are any non-trivial fields, then there can be no non-exhaustive 1-zsts. // Otherwise, it's only an issue if there's >1 non-exhaustive 1-zst. if non_trivial_count > 0 || prev_non_exhaustive_1zst { - tcx.struct_span_lint_hir( + tcx.node_span_lint( REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS, tcx.local_def_id_to_hir_id(adt.did().expect_local()), span, diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs index db619d5169e42..d03b02f028da1 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs @@ -270,7 +270,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { if !spans.is_empty() { let (default_modifier, default_result) = reg_class.default_modifier(asm_arch).unwrap(); - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( lint::builtin::ASM_SUB_REGISTER, expr.hir_id, spans, diff --git a/compiler/rustc_hir_analysis/src/check_unused.rs b/compiler/rustc_hir_analysis/src/check_unused.rs index 36cb8f7a20228..aa5db4f6aa7bb 100644 --- a/compiler/rustc_hir_analysis/src/check_unused.rs +++ b/compiler/rustc_hir_analysis/src/check_unused.rs @@ -40,12 +40,6 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) { } else { "unused import".to_owned() }; - tcx.struct_span_lint_hir( - lint::builtin::UNUSED_IMPORTS, - item.hir_id(), - path.span, - msg, - |_| {}, - ); + tcx.node_span_lint(lint::builtin::UNUSED_IMPORTS, item.hir_id(), path.span, msg, |_| {}); } } diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index c1d0e0444b673..1736de760d5a6 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -495,7 +495,7 @@ fn lint_auto_trait_impl<'tcx>( return; } - tcx.struct_span_lint_hir( + tcx.node_span_lint( lint::builtin::SUSPICIOUS_AUTO_TRAIT_IMPLS, tcx.local_def_id_to_hir_id(impl_def_id), tcx.def_span(impl_def_id), diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index b44b2eefabbc6..c29d413184304 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -274,7 +274,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { Defaults::FutureCompatDisallowed if tcx.features().default_type_parameter_fallback => {} Defaults::FutureCompatDisallowed => { - tcx.struct_span_lint_hir( + tcx.node_span_lint( lint::builtin::INVALID_TYPE_PARAM_DEFAULT, param.hir_id, param.span, diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 4f049f699e6c8..a857e01f4fa7b 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -912,7 +912,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { continue; } self.insert_lifetime(lt, ResolvedArg::StaticLifetime); - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( lint::builtin::UNUSED_LIFETIMES, lifetime.hir_id, lifetime.ident.span, diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 3ea409827b4b7..09dbfaa57d248 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -62,7 +62,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind); let msg = format!("unreachable {kind}"); - self.tcx().struct_span_lint_hir( + self.tcx().node_span_lint( lint::builtin::UNREACHABLE_CODE, id, span, diff --git a/compiler/rustc_hir_typeck/src/method/prelude2021.rs b/compiler/rustc_hir_typeck/src/method/prelude2021.rs index 43d258de6ca7a..0e43cb40485a5 100644 --- a/compiler/rustc_hir_typeck/src/method/prelude2021.rs +++ b/compiler/rustc_hir_typeck/src/method/prelude2021.rs @@ -77,7 +77,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Inherent impls only require not relying on autoref and autoderef in order to // ensure that the trait implementation won't be used - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( prelude_or_array_lint, self_expr.hir_id, self_expr.span, @@ -127,7 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { // trait implementations require full disambiguation to not clash with the new prelude // additions (i.e. convert from dot-call to fully-qualified call) - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( prelude_or_array_lint, call_expr.hir_id, call_expr.span, @@ -238,7 +238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return; } - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( RUST_2021_PRELUDE_COLLISIONS, expr_id, span, diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 4dc802008d032..17eff54f7ae87 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -440,7 +440,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if self.tcx.sess.at_least_rust_2018() { self.dcx().emit_err(MethodCallOnUnknownRawPointee { span }); } else { - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( lint::builtin::TYVAR_BEHIND_RAW_POINTER, scope_expr_id, span, @@ -1380,7 +1380,7 @@ impl<'tcx> Pick<'tcx> { return; } let def_kind = self.item.kind.as_def_kind(); - tcx.struct_span_lint_hir( + tcx.node_span_lint( lint::builtin::UNSTABLE_NAME_COLLISIONS, scope_expr_id, span, diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 3710686727703..73fc0ee499e6e 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -1840,7 +1840,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &unmentioned_fields.iter().map(|(_, i)| i).collect::>(), ); - self.tcx.struct_span_lint_hir(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, "some fields are not explicitly listed", |lint| { + self.tcx.node_span_lint(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, "some fields are not explicitly listed", |lint| { lint.span_label(pat.span, format!("field{} {} not listed", rustc_errors::pluralize!(unmentioned_fields.len()), joined_patterns)); lint.help( "ensure that all fields are mentioned explicitly by adding the suggested fields", diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index f6b05e1b35a6c..82c5e566f161c 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -754,7 +754,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let closure_hir_id = self.tcx.local_def_id_to_hir_id(closure_def_id); let closure_head_span = self.tcx.def_span(closure_def_id); - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_hir_id, closure_head_span, diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 5c34b763e5d50..163507c1d50b5 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -676,7 +676,7 @@ impl<'tcx> LintContext for LateContext<'tcx> { let hir_id = self.last_node_with_lint_attrs; match span { - Some(s) => self.tcx.struct_span_lint_hir(lint, hir_id, s, msg, decorate), + Some(s) => self.tcx.node_span_lint(lint, hir_id, s, msg, decorate), None => self.tcx.node_lint(lint, hir_id, msg, decorate), } } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 70506313832b4..1f87e5f5f943b 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -248,7 +248,7 @@ pub fn explain_lint_level_source( /// If you are looking to implement a lint, look for higher level functions, /// for example: /// - [`TyCtxt::emit_spanned_lint`] -/// - [`TyCtxt::struct_span_lint_hir`] +/// - [`TyCtxt::node_span_lint`] /// - [`TyCtxt::emit_lint`] /// - [`TyCtxt::node_lint`] /// - `LintContext::opt_span_lint` diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index efe7bdfa06db1..afb6937b43b94 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -217,7 +217,7 @@ fn late_report_deprecation( return; } let method_span = method_span.unwrap_or(span); - tcx.struct_span_lint_hir(lint, hir_id, method_span, message, |diag| { + tcx.node_span_lint(lint, hir_id, method_span, message, |diag| { if let hir::Node::Expr(_) = tcx.hir_node(hir_id) { let kind = tcx.def_descr(def_id); deprecation_suggestion(diag, kind, suggestion, method_span); @@ -585,7 +585,7 @@ impl<'tcx> TyCtxt<'tcx> { unmarked: impl FnOnce(Span, DefId), ) -> bool { let soft_handler = |lint, span, msg: String| { - self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg, |_| {}) + self.node_span_lint(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg, |_| {}) }; let eval_result = self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable); diff --git a/compiler/rustc_middle/src/mir/interpret/queries.rs b/compiler/rustc_middle/src/mir/interpret/queries.rs index b20df1b23434e..5f9e7f6e36854 100644 --- a/compiler/rustc_middle/src/mir/interpret/queries.rs +++ b/compiler/rustc_middle/src/mir/interpret/queries.rs @@ -108,7 +108,7 @@ impl<'tcx> TyCtxt<'tcx> { let mir_body = self.mir_for_ctfe(instance.def_id()); if mir_body.is_polymorphic { let Some(local_def_id) = ct.def.as_local() else { return }; - self.struct_span_lint_hir( + self.node_span_lint( lint::builtin::CONST_EVALUATABLE_UNCHECKED, self.local_def_id_to_hir_id(local_def_id), self.def_span(ct.def), diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9d55c74d54b91..cb9fbde35d478 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2096,7 +2096,7 @@ impl<'tcx> TyCtxt<'tcx> { /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_span_lint_hir( + pub fn node_span_lint( self, lint: &'static Lint, hir_id: HirId, diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 6e68dee76a24c..3289dfe343e1a 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -161,7 +161,7 @@ fn lint_object_unsafe_trait( ) { // Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise id. // It's also hard to get a use site span, so we use the method definition span. - tcx.struct_span_lint_hir( + tcx.node_span_lint( WHERE_CLAUSES_OBJECT_SAFETY, hir::CRATE_HIR_ID, span, diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index 910fc0ee31463..bfc6937a3eb39 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -462,7 +462,7 @@ fn report_conflicting_impls<'tcx>( FutureCompatOverlapErrorKind::Issue33140 => ORDER_DEPENDENT_TRAIT_OBJECTS, FutureCompatOverlapErrorKind::LeakCheck => COHERENCE_LEAK_CHECK, }; - tcx.struct_span_lint_hir( + tcx.node_span_lint( lint, tcx.local_def_id_to_hir_id(impl_def_id), impl_span, diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index bad1511dfd29e..ee5891c12fc5a 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -827,7 +827,7 @@ impl<'tcx> ExtraInfo<'tcx> { fn error_invalid_codeblock_attr(&self, msg: impl Into) { if let Some(def_id) = self.def_id.as_local() { - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( crate::lint::INVALID_CODEBLOCK_ATTRIBUTES, self.tcx.local_def_id_to_hir_id(def_id), self.sp, @@ -843,7 +843,7 @@ impl<'tcx> ExtraInfo<'tcx> { f: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), ) { if let Some(def_id) = self.def_id.as_local() { - self.tcx.struct_span_lint_hir( + self.tcx.node_span_lint( crate::lint::INVALID_CODEBLOCK_ATTRIBUTES, self.tcx.local_def_id_to_hir_id(def_id), self.sp, diff --git a/src/librustdoc/passes/check_doc_test_visibility.rs b/src/librustdoc/passes/check_doc_test_visibility.rs index a931e8804d9cb..0603aae553609 100644 --- a/src/librustdoc/passes/check_doc_test_visibility.rs +++ b/src/librustdoc/passes/check_doc_test_visibility.rs @@ -126,7 +126,7 @@ pub(crate) fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item if should_have_doc_example(cx, item) { debug!("reporting error for {item:?} (hir_id={hir_id:?})"); let sp = item.attr_span(cx.tcx); - cx.tcx.struct_span_lint_hir( + cx.tcx.node_span_lint( crate::lint::MISSING_DOC_CODE_EXAMPLES, hir_id, sp, @@ -137,7 +137,7 @@ pub(crate) fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item } else if tests.found_tests > 0 && !cx.cache.effective_visibilities.is_exported(cx.tcx, item.item_id.expect_def_id()) { - cx.tcx.struct_span_lint_hir( + cx.tcx.node_span_lint( crate::lint::PRIVATE_DOC_TESTS, hir_id, item.attr_span(cx.tcx), diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 30b3e5c784dc1..ca1870a3a645c 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1704,7 +1704,7 @@ fn report_diagnostic( let sp = item.attr_span(tcx); - tcx.struct_span_lint_hir(lint, hir_id, sp, msg, |lint| { + tcx.node_span_lint(lint, hir_id, sp, msg, |lint| { let (span, link_range) = match link_range { MarkdownLinkRange::Destination(md_range) => { let mut md_range = md_range.clone(); diff --git a/src/librustdoc/passes/lint/bare_urls.rs b/src/librustdoc/passes/lint/bare_urls.rs index bffa17da3b4c7..c6989fbbf255e 100644 --- a/src/librustdoc/passes/lint/bare_urls.rs +++ b/src/librustdoc/passes/lint/bare_urls.rs @@ -24,7 +24,7 @@ pub(super) fn visit_item(cx: &DocContext<'_>, item: &Item) { let sp = source_span_for_markdown_range(cx.tcx, &dox, &range, &item.attrs.doc_strings) .unwrap_or_else(|| item.attr_span(cx.tcx)); - cx.tcx.struct_span_lint_hir(crate::lint::BARE_URLS, hir_id, sp, msg, |lint| { + cx.tcx.node_span_lint(crate::lint::BARE_URLS, hir_id, sp, msg, |lint| { lint.note("bare URLs are not automatically turned into clickable links") .span_suggestion( sp, diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs index 782938f10943f..e73649c722493 100644 --- a/src/librustdoc/passes/lint/check_code_block_syntax.rs +++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs @@ -99,7 +99,7 @@ fn check_rust_syntax( // All points of divergence have been handled earlier so this can be // done the same way whether the span is precise or not. let hir_id = cx.tcx.local_def_id_to_hir_id(local_id); - cx.tcx.struct_span_lint_hir(crate::lint::INVALID_RUST_CODEBLOCKS, hir_id, sp, msg, |lint| { + cx.tcx.node_span_lint(crate::lint::INVALID_RUST_CODEBLOCKS, hir_id, sp, msg, |lint| { let explanation = if is_ignore { "`ignore` code blocks require valid Rust code for syntax highlighting; \ mark blocks that do not contain Rust code as text" diff --git a/src/librustdoc/passes/lint/html_tags.rs b/src/librustdoc/passes/lint/html_tags.rs index 90874c01102e5..da3770aa927af 100644 --- a/src/librustdoc/passes/lint/html_tags.rs +++ b/src/librustdoc/passes/lint/html_tags.rs @@ -25,7 +25,7 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) { Some(sp) => sp, None => item.attr_span(tcx), }; - tcx.struct_span_lint_hir(crate::lint::INVALID_HTML_TAGS, hir_id, sp, msg, |lint| { + tcx.node_span_lint(crate::lint::INVALID_HTML_TAGS, hir_id, sp, msg, |lint| { use rustc_lint_defs::Applicability; // If a tag looks like ``, it might actually be a generic. // We don't try to detect stuff `` because that's not valid HTML, diff --git a/src/librustdoc/passes/lint/redundant_explicit_links.rs b/src/librustdoc/passes/lint/redundant_explicit_links.rs index 73f6a42636064..9069098bf1a37 100644 --- a/src/librustdoc/passes/lint/redundant_explicit_links.rs +++ b/src/librustdoc/passes/lint/redundant_explicit_links.rs @@ -176,7 +176,7 @@ fn check_inline_or_reference_unknown_redundancy( &item.attrs.doc_strings, )?; - cx.tcx.struct_span_lint_hir(crate::lint::REDUNDANT_EXPLICIT_LINKS, hir_id, explicit_span, "redundant explicit link target", |lint| { + cx.tcx.node_span_lint(crate::lint::REDUNDANT_EXPLICIT_LINKS, hir_id, explicit_span, "redundant explicit link target", |lint| { lint.span_label(explicit_span, "explicit target is redundant") .span_label(display_span, "because label contains path that resolves to same destination") .note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links") @@ -226,7 +226,7 @@ fn check_reference_redundancy( &item.attrs.doc_strings, )?; - cx.tcx.struct_span_lint_hir(crate::lint::REDUNDANT_EXPLICIT_LINKS, hir_id, explicit_span, "redundant explicit link target", |lint| { + cx.tcx.node_span_lint(crate::lint::REDUNDANT_EXPLICIT_LINKS, hir_id, explicit_span, "redundant explicit link target", |lint| { lint.span_label(explicit_span, "explicit target is redundant") .span_label(display_span, "because label contains path that resolves to same destination") .span_note(def_span, "referenced explicit link target defined here") diff --git a/src/librustdoc/passes/lint/unescaped_backticks.rs b/src/librustdoc/passes/lint/unescaped_backticks.rs index 0893cd0b40b52..dbbf39362e316 100644 --- a/src/librustdoc/passes/lint/unescaped_backticks.rs +++ b/src/librustdoc/passes/lint/unescaped_backticks.rs @@ -56,7 +56,7 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) { ) .unwrap_or_else(|| item.attr_span(tcx)); - tcx.struct_span_lint_hir(crate::lint::UNESCAPED_BACKTICKS, hir_id, span, "unescaped backtick", |lint| { + tcx.node_span_lint(crate::lint::UNESCAPED_BACKTICKS, hir_id, span, "unescaped backtick", |lint| { let mut help_emitted = false; match element.prev_code_guess { diff --git a/src/tools/clippy/clippy.toml b/src/tools/clippy/clippy.toml index afadbb032b76a..8c405ac6a4e82 100644 --- a/src/tools/clippy/clippy.toml +++ b/src/tools/clippy/clippy.toml @@ -3,5 +3,5 @@ avoid-breaking-exported-api = false # use the various `span_lint_*` methods instead, which also add a link to the docs disallowed-methods = [ "rustc_lint::context::LintContext::span_lint", - "rustc_middle::ty::context::TyCtxt::struct_span_lint_hir" + "rustc_middle::ty::context::TyCtxt::node_span_lint" ] diff --git a/src/tools/clippy/clippy_utils/src/diagnostics.rs b/src/tools/clippy/clippy_utils/src/diagnostics.rs index 86a43cb367f87..56978eb2ee805 100644 --- a/src/tools/clippy/clippy_utils/src/diagnostics.rs +++ b/src/tools/clippy/clippy_utils/src/diagnostics.rs @@ -154,7 +154,7 @@ where pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: &str) { #[expect(clippy::disallowed_methods)] - cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg.to_string(), |diag| { + cx.tcx.node_span_lint(lint, hir_id, sp, msg.to_string(), |diag| { docs_link(diag, lint); }); } @@ -168,7 +168,7 @@ pub fn span_lint_hir_and_then( f: impl FnOnce(&mut Diagnostic), ) { #[expect(clippy::disallowed_methods)] - cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg.to_string(), |diag| { + cx.tcx.node_span_lint(lint, hir_id, sp, msg.to_string(), |diag| { f(diag); docs_link(diag, lint); }); diff --git a/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs b/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs index 8b605b5a7e1df..b9b4a07d29d0e 100644 --- a/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs +++ b/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs @@ -21,7 +21,7 @@ pub fn b( span: impl Into, msg: impl Into, ) { - tcx.struct_span_lint_hir(lint, hir_id, span, msg, |_| {}); + tcx.node_span_lint(lint, hir_id, span, msg, |_| {}); } fn main() {} diff --git a/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr b/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr index 9b1010a1b6d24..03556823a8f50 100644 --- a/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr +++ b/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr @@ -7,10 +7,10 @@ LL | cx.span_lint(lint, span, msg, |_| {}); = note: `-D clippy::disallowed-methods` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]` -error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::struct_span_lint_hir` +error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint` --> $DIR/disallow_struct_span_lint.rs:24:5 | -LL | tcx.struct_span_lint_hir(lint, hir_id, span, msg, |_| {}); +LL | tcx.node_span_lint(lint, hir_id, span, msg, |_| {}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors From 82ca070c1680004da7d25abcc1d3d793d00abf06 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 16:17:08 +1100 Subject: [PATCH 09/11] Rename `TyCtxt::emit_lint` as `TyCtxt::emit_node_lint`. --- compiler/rustc_middle/src/lint.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 1f87e5f5f943b..7e8261729ccb1 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -249,7 +249,7 @@ pub fn explain_lint_level_source( /// for example: /// - [`TyCtxt::emit_spanned_lint`] /// - [`TyCtxt::node_span_lint`] -/// - [`TyCtxt::emit_lint`] +/// - [`TyCtxt::emit_node_lint`] /// - [`TyCtxt::node_lint`] /// - `LintContext::opt_span_lint` /// diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index cb9fbde35d478..1ea80aa4fb561 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2111,7 +2111,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically /// generated by `#[derive(LintDiagnostic)]`). #[track_caller] - pub fn emit_lint( + pub fn emit_node_lint( self, lint: &'static Lint, id: HirId, From e164cf30f8f96551cedece4ed199d7ecb5832648 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 16:27:02 +1100 Subject: [PATCH 10/11] Rename `TyCtxt::emit_spanned_lint` as `TyCtxt::emit_node_span_lint`. --- compiler/rustc_borrowck/src/lib.rs | 2 +- .../rustc_const_eval/src/const_eval/error.rs | 2 +- .../src/const_eval/machine.rs | 2 +- .../src/astconv/object_safety.rs | 2 +- .../src/check/compare_impl_item/refine.rs | 2 +- compiler/rustc_hir_analysis/src/check/errs.rs | 2 +- compiler/rustc_hir_typeck/src/cast.rs | 8 +- compiler/rustc_lint/src/async_fn_in_trait.rs | 2 +- compiler/rustc_lint/src/expect.rs | 2 +- compiler/rustc_lint/src/foreign_modules.rs | 2 +- compiler/rustc_middle/src/lint.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 2 +- .../rustc_mir_build/src/check_unsafety.rs | 24 +++--- compiler/rustc_mir_build/src/lints.rs | 2 +- .../src/thir/pattern/check_match.rs | 10 +-- .../src/thir/pattern/const_to_pat.rs | 14 ++-- .../src/check_const_item_mutation.rs | 4 +- .../rustc_mir_transform/src/check_unsafety.rs | 4 +- .../src/const_prop_lint.rs | 2 +- compiler/rustc_mir_transform/src/coroutine.rs | 2 +- .../src/ffi_unwind_calls.rs | 2 +- .../src/function_item_references.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 2 +- compiler/rustc_passes/src/check_attr.rs | 84 +++++++++---------- compiler/rustc_passes/src/dead.rs | 4 +- compiler/rustc_passes/src/liveness.rs | 18 ++-- compiler/rustc_passes/src/naked_functions.rs | 2 +- compiler/rustc_passes/src/stability.rs | 8 +- compiler/rustc_pattern_analysis/src/lints.rs | 2 +- compiler/rustc_pattern_analysis/src/rustc.rs | 2 +- compiler/rustc_privacy/src/lib.rs | 6 +- .../error_reporting/on_unimplemented.rs | 12 +-- 32 files changed, 118 insertions(+), 118 deletions(-) diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index b304fb5589f37..177fc1deca12a 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -415,7 +415,7 @@ fn do_mir_borrowck<'tcx>( let mut_span = tcx.sess.source_map().span_until_non_whitespace(span); - tcx.emit_spanned_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span }) + tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span }) } let tainted_by_errors = mbcx.emit_errors(); diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index ef39d13d78ab4..e8d0430c9d955 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -175,7 +175,7 @@ pub(super) fn lint<'tcx, 'mir, L>( { let (span, frames) = get_span_and_frames(tcx, machine); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( lint, // We use the root frame for this so the crate that defines the const defines whether the // lint is emitted. diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 6947ace17c5e6..f2e8821d6b65b 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -611,7 +611,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, .0 .is_error(); let span = ecx.cur_span(); - ecx.tcx.emit_spanned_lint( + ecx.tcx.emit_node_span_lint( rustc_session::lint::builtin::LONG_RUNNING_CONST_EVAL, hir_id, span, diff --git a/compiler/rustc_hir_analysis/src/astconv/object_safety.rs b/compiler/rustc_hir_analysis/src/astconv/object_safety.rs index 8967b51749c82..5f35f75c77b0f 100644 --- a/compiler/rustc_hir_analysis/src/astconv/object_safety.rs +++ b/compiler/rustc_hir_analysis/src/astconv/object_safety.rs @@ -220,7 +220,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let def_id = projection_bound.projection_def_id(); def_ids.remove(&def_id); if tcx.generics_require_sized_self(def_id) { - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNUSED_ASSOCIATED_TYPE_BOUNDS, hir_id, *span, diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index 0d8de0cabd1af..6d2ebb150b957 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -283,7 +283,7 @@ fn report_mismatched_rpitit_signature<'tcx>( }); let span = unmatched_bound.unwrap_or(span); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( REFINING_IMPL_TRAIT, tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()), span, diff --git a/compiler/rustc_hir_analysis/src/check/errs.rs b/compiler/rustc_hir_analysis/src/check/errs.rs index 27bb2c57a5cb7..87a1f3d342580 100644 --- a/compiler/rustc_hir_analysis/src/check/errs.rs +++ b/compiler/rustc_hir_analysis/src/check/errs.rs @@ -88,7 +88,7 @@ fn handle_static_mut_ref( "shared ", ) }; - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( STATIC_MUT_REF, hir_id, span, diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index a720a858f3c13..bd8a2024caa1e 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -587,7 +587,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { }; let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty); let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty); - fcx.tcx.emit_spanned_lint( + fcx.tcx.emit_node_span_lint( lint, self.expr.hir_id, self.span, @@ -900,7 +900,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty); let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty); - fcx.tcx.emit_spanned_lint( + fcx.tcx.emit_node_span_lint( lint::builtin::CENUM_IMPL_DROP_CAST, self.expr.hir_id, self.span, @@ -934,7 +934,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { }; let lint = errors::LossyProvenancePtr2Int { expr_ty, cast_ty, sugg }; - fcx.tcx.emit_spanned_lint( + fcx.tcx.emit_node_span_lint( lint::builtin::LOSSY_PROVENANCE_CASTS, self.expr.hir_id, self.span, @@ -950,7 +950,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty); let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty); let lint = errors::LossyProvenanceInt2Ptr { expr_ty, cast_ty, sugg }; - fcx.tcx.emit_spanned_lint( + fcx.tcx.emit_node_span_lint( lint::builtin::FUZZY_PROVENANCE_CASTS, self.expr.hir_id, self.span, diff --git a/compiler/rustc_lint/src/async_fn_in_trait.rs b/compiler/rustc_lint/src/async_fn_in_trait.rs index 512136473617c..5f7a3137d52d4 100644 --- a/compiler/rustc_lint/src/async_fn_in_trait.rs +++ b/compiler/rustc_lint/src/async_fn_in_trait.rs @@ -116,7 +116,7 @@ impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait { def.owner_id.def_id, " + Send", ); - cx.tcx.emit_spanned_lint( + cx.tcx.emit_node_span_lint( ASYNC_FN_IN_TRAIT, item.hir_id(), async_span, diff --git a/compiler/rustc_lint/src/expect.rs b/compiler/rustc_lint/src/expect.rs index 2b6290e8a0067..40db765da53a9 100644 --- a/compiler/rustc_lint/src/expect.rs +++ b/compiler/rustc_lint/src/expect.rs @@ -29,7 +29,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option) { { let rationale = expectation.reason.map(|rationale| ExpectationNote { rationale }); let note = expectation.is_unfulfilled_lint_expectations.then_some(()); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNFULFILLED_LINT_EXPECTATIONS, *hir_id, expectation.emission_span, diff --git a/compiler/rustc_lint/src/foreign_modules.rs b/compiler/rustc_lint/src/foreign_modules.rs index ecb7a157f39bb..b995f38f23c6e 100644 --- a/compiler/rustc_lint/src/foreign_modules.rs +++ b/compiler/rustc_lint/src/foreign_modules.rs @@ -161,7 +161,7 @@ impl ClashingExternDeclarations { sub, } }; - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( CLASHING_EXTERN_DECLARATIONS, this_fi.hir_id(), mismatch_label, diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 7e8261729ccb1..c545300cb8080 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -247,7 +247,7 @@ pub fn explain_lint_level_source( /// /// If you are looking to implement a lint, look for higher level functions, /// for example: -/// - [`TyCtxt::emit_spanned_lint`] +/// - [`TyCtxt::emit_node_span_lint`] /// - [`TyCtxt::node_span_lint`] /// - [`TyCtxt::emit_node_lint`] /// - [`TyCtxt::node_lint`] diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 1ea80aa4fb561..cd3a899a5f41b 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2077,7 +2077,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`, /// typically generated by `#[derive(LintDiagnostic)]`). #[track_caller] - pub fn emit_spanned_lint( + pub fn emit_node_span_lint( self, lint: &'static Lint, hir_id: HirId, diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index b4a02fae4544b..ac147afaab313 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -599,7 +599,7 @@ impl UnsafeOpKind { // FIXME: ideally we would want to trim the def paths, but this is not // feasible with the current lint emission API (see issue #106126). match self { - CallToUnsafeFunction(Some(did)) => tcx.emit_spanned_lint( + CallToUnsafeFunction(Some(did)) => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -609,7 +609,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - CallToUnsafeFunction(None) => tcx.emit_spanned_lint( + CallToUnsafeFunction(None) => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -618,7 +618,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - UseOfInlineAssembly => tcx.emit_spanned_lint( + UseOfInlineAssembly => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -627,7 +627,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - InitializingTypeWith => tcx.emit_spanned_lint( + InitializingTypeWith => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -636,7 +636,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - UseOfMutableStatic => tcx.emit_spanned_lint( + UseOfMutableStatic => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -645,7 +645,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - UseOfExternStatic => tcx.emit_spanned_lint( + UseOfExternStatic => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -654,7 +654,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - DerefOfRawPointer => tcx.emit_spanned_lint( + DerefOfRawPointer => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -663,7 +663,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - AccessToUnionField => tcx.emit_spanned_lint( + AccessToUnionField => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -672,7 +672,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - MutationOfLayoutConstrainedField => tcx.emit_spanned_lint( + MutationOfLayoutConstrainedField => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -681,7 +681,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - BorrowOfLayoutConstrainedField => tcx.emit_spanned_lint( + BorrowOfLayoutConstrainedField => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -690,7 +690,7 @@ impl UnsafeOpKind { unsafe_not_inherited_note, }, ), - CallToFunctionWith { function, missing, build_enabled } => tcx.emit_spanned_lint( + CallToFunctionWith { function, missing, build_enabled } => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -941,7 +941,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) { warnings.sort_by_key(|w| w.block_span); for UnusedUnsafeWarning { hir_id, block_span, enclosing_unsafe } in warnings { let block_span = tcx.sess.source_map().guess_head_span(block_span); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNUSED_UNSAFE, hir_id, block_span, diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index 167b65328d11a..337493d15deca 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -53,7 +53,7 @@ fn check_recursion<'tcx>( let sp = tcx.def_span(def_id); let hir_id = tcx.local_def_id_to_hir_id(def_id); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNCONDITIONAL_RECURSION, hir_id, sp, 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 03de79e92be8f..ce75a2831a51e 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -539,7 +539,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { let span_end = prefix.last().unwrap().unwrap().0; let span = span_start.to(span_end); let count = prefix.len(); - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( IRREFUTABLE_LET_PATTERNS, self.lint_level, span, @@ -558,7 +558,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { let span_end = suffix.last().unwrap().unwrap().0; let span = span_start.to(span_end); let count = suffix.len(); - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( IRREFUTABLE_LET_PATTERNS, self.lint_level, span, @@ -814,7 +814,7 @@ fn check_for_bindings_named_same_as_variants( { let variant_count = edef.variants().len(); let ty_path = with_no_trimmed_paths!(cx.tcx.def_path_str(edef.did())); - cx.tcx.emit_spanned_lint( + cx.tcx.emit_node_span_lint( BINDINGS_WITH_VARIANT_NAME, cx.lint_level, pat.span, @@ -856,7 +856,7 @@ fn report_irrefutable_let_patterns( ) { macro_rules! emit_diag { ($lint:tt) => {{ - tcx.emit_spanned_lint(IRREFUTABLE_LET_PATTERNS, id, span, $lint { count }); + tcx.emit_node_span_lint(IRREFUTABLE_LET_PATTERNS, id, span, $lint { count }); }}; } @@ -876,7 +876,7 @@ fn report_unreachable_pattern<'p, 'tcx>( span: Span, catchall: Option, ) { - cx.tcx.emit_spanned_lint( + cx.tcx.emit_node_span_lint( UNREACHABLE_PATTERNS, hir_id, span, diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 5631a38d0f0db..22305f03a769d 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -214,7 +214,7 @@ impl<'tcx> ConstToPat<'tcx> { if let Some(mir_structural_match_violation) = mir_structural_match_violation { match non_sm_ty.kind() { ty::Adt(..) if mir_structural_match_violation => { - self.tcx().emit_spanned_lint( + self.tcx().emit_node_span_lint( lint::builtin::INDIRECT_STRUCTURAL_MATCH, self.id, self.span, @@ -233,7 +233,7 @@ impl<'tcx> ConstToPat<'tcx> { } else if !have_valtree && !self.saw_const_match_lint.get() { // The only way valtree construction can fail without the structural match // checker finding a violation is if there is a pointer somewhere. - self.tcx().emit_spanned_lint( + self.tcx().emit_node_span_lint( lint::builtin::POINTER_STRUCTURAL_MATCH, self.id, self.span, @@ -244,7 +244,7 @@ impl<'tcx> ConstToPat<'tcx> { // Always check for `PartialEq`, even if we emitted other lints. (But not if there were // any errors.) This ensures it shows up in cargo's future-compat reports as well. if !self.type_has_partial_eq_impl(cv.ty()) { - self.tcx().emit_spanned_lint( + self.tcx().emit_node_span_lint( lint::builtin::CONST_PATTERNS_WITHOUT_PARTIAL_EQ, self.id, self.span, @@ -319,7 +319,7 @@ impl<'tcx> ConstToPat<'tcx> { let kind = match ty.kind() { ty::Float(_) => { self.saw_const_match_lint.set(true); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, id, span, @@ -339,7 +339,7 @@ impl<'tcx> ConstToPat<'tcx> { ty::Adt(..) if !self.type_marked_structural(ty) && self.behind_reference.get() => { if self.saw_const_match_error.get().is_none() && !self.saw_const_match_lint.get() { self.saw_const_match_lint.set(true); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( lint::builtin::INDIRECT_STRUCTURAL_MATCH, id, span, @@ -435,7 +435,7 @@ impl<'tcx> ConstToPat<'tcx> { && !self.saw_const_match_lint.get() { self.saw_const_match_lint.set(true); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( lint::builtin::INDIRECT_STRUCTURAL_MATCH, self.id, span, @@ -516,7 +516,7 @@ impl<'tcx> ConstToPat<'tcx> { && let Some(non_sm_ty) = traits::search_for_structural_match_violation(span, tcx, ty) { self.saw_const_match_lint.set(true); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( lint::builtin::NONTRIVIAL_STRUCTURAL_MATCH, id, span, diff --git a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs index 3195cd3622dc9..1f615c9d8d1a2 100644 --- a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs +++ b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs @@ -100,7 +100,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> { && let Some((lint_root, span, item)) = self.should_lint_const_item_usage(lhs, def_id, loc) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( CONST_ITEM_MUTATION, lint_root, span, @@ -145,7 +145,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> { if let Some((lint_root, span, item)) = self.should_lint_const_item_usage(place, def_id, lint_loc) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( CONST_ITEM_MUTATION, lint_root, span, diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs index 582c2c0c6b60b..6c4c3917cb5ec 100644 --- a/compiler/rustc_mir_transform/src/check_unsafety.rs +++ b/compiler/rustc_mir_transform/src/check_unsafety.rs @@ -527,7 +527,7 @@ fn report_unused_unsafe(tcx: TyCtxt<'_>, kind: UnusedUnsafe, id: HirId) { } else { None }; - tcx.emit_spanned_lint(UNUSED_UNSAFE, id, span, errors::UnusedUnsafe { span, nested_parent }); + tcx.emit_node_span_lint(UNUSED_UNSAFE, id, span, errors::UnusedUnsafe { span, nested_parent }); } pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) { @@ -577,7 +577,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) { }); } UnsafetyViolationKind::UnsafeFn => { - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, lint_root, source_info.span, diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index d0bbca08a4068..b8fecaf635aa2 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -278,7 +278,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { fn report_assert_as_lint(&self, source_info: &SourceInfo, lint: AssertLint) { if let Some(lint_root) = self.lint_root(*source_info) { - self.tcx.emit_spanned_lint(lint.lint(), lint_root, source_info.span, lint); + self.tcx.emit_node_span_lint(lint.lint(), lint_root, source_info.span, lint); } } diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index eaa36e0cc91eb..347f9b49efe88 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -2071,7 +2071,7 @@ fn check_must_not_suspend_def( span: data.source_span, reason: s.as_str().to_string(), }); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( rustc_session::lint::builtin::MUST_NOT_SUSPEND, hir_id, data.source_span, diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 26fcfad828777..c47abb4fcb478 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -112,7 +112,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { let span = terminator.source_info.span; let foreign = fn_def_id.is_some(); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( FFI_UNWIND_CALLS, lint_root, span, diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index 61d99f1f018b5..f413bd9b31168 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -185,7 +185,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { ret, ); - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( FUNCTION_ITEM_REFERENCES, lint_root, span, diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 20e70f87b75e8..3e09066141452 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -714,7 +714,7 @@ impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> { // but correct span? This would make the lint at least accept crate-level lint attributes. return; }; - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( LARGE_ASSIGNMENTS, lint_root, span, diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 20ed2573e3a71..9d9741bbe8947 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -246,13 +246,13 @@ impl<'tcx> CheckAttrVisitor<'tcx> { attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name)) { match attr.style { - ast::AttrStyle::Outer => self.tcx.emit_spanned_lint( + ast::AttrStyle::Outer => self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, errors::OuterCrateLevelAttr, ), - ast::AttrStyle::Inner => self.tcx.emit_spanned_lint( + ast::AttrStyle::Inner => self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -274,7 +274,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } fn inline_attr_str_error_with_macro_def(&self, hir_id: HirId, attr: &Attribute, sym: &str) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -283,7 +283,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } fn inline_attr_str_error_without_macro_def(&self, hir_id: HirId, attr: &Attribute, sym: &str) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -304,7 +304,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { /// Checks if `#[diagnostic::on_unimplemented]` is applied to a trait definition fn check_diagnostic_on_unimplemented(&self, attr_span: Span, hir_id: HirId, target: Target) { if !matches!(target, Target::Trait) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, hir_id, attr_span, @@ -320,7 +320,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | Target::Closure | Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true, Target::Method(MethodKind::Trait { body: false }) | Target::ForeignFn => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -333,7 +333,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // accidentally, to be compatible with crates depending on them, we can't throw an // error here. Target::AssocConst => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -366,7 +366,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // function prototypes can't be covered Target::Method(MethodKind::Trait { body: false }) | Target::ForeignFn => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -376,7 +376,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } Target::Mod | Target::ForeignMod | Target::Impl | Target::Trait => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -386,7 +386,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } Target::Expression | Target::Statement | Target::Arm => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -413,7 +413,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { allowed_target: Target, ) { if target != allowed_target { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -630,7 +630,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // FIXME: #[target_feature] was previously erroneously allowed on statements and some // crates used this, so only emit a warning. Target::Statement => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -769,7 +769,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { return false; } if let Err(entry) = aliases.try_insert(doc_alias_str.to_owned(), span) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, span, @@ -914,7 +914,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } _ => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, meta.span(), @@ -937,7 +937,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { target: Target, ) -> bool { if target != Target::ExternCrate { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, meta.span(), @@ -951,7 +951,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } if self.tcx.extern_mod_stmt_cnum(hir_id.owner).is_none() { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, meta.span(), @@ -996,7 +996,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { .then_some(errors::AttrCrateLevelOnlySugg { attr: attr.span.with_lo(bang_span).with_hi(bang_span), }); - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, meta.span(), @@ -1016,7 +1016,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { match (i_meta.name_or_empty(), i_meta.meta_item()) { (sym::attr | sym::no_crate_inject, _) => {} (_, Some(m)) => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, i_meta.span(), @@ -1027,7 +1027,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { is_valid = false; } (_, None) => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, i_meta.span(), @@ -1038,7 +1038,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } } else { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, meta.span(), @@ -1055,7 +1055,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { if meta.meta_item_list().is_some() { true } else { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, meta.span(), @@ -1188,7 +1188,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { _ => { let path = rustc_ast_pretty::pprust::path_to_string(&i_meta.path); if i_meta.has_name(sym::spotlight) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, i_meta.span, @@ -1204,7 +1204,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { }; // If there are multiple attributes, the suggestion would suggest // deleting all of them, which is incorrect. - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, i_meta.span, @@ -1219,7 +1219,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { }, ); } else { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, i_meta.span, @@ -1230,7 +1230,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } } else { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, meta.span(), @@ -1343,7 +1343,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { _ => "a", }; - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -1380,7 +1380,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { _ => { // FIXME: #[cold] was previously allowed on non-functions and some crates used // this, so only emit a warning. - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -1400,7 +1400,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { return; } - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -1424,14 +1424,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // used this, so only emit a warning. let attr_span = matches!(target, Target::ForeignMod).then_some(attr.span); if let Some(s) = attr.value_str() { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, errors::LinkName { span, attr_span, value: s.as_str() }, ); } else { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -1710,7 +1710,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { _ => { // FIXME: #[link_section] was previously allowed on non-functions/statics and some // crates used this, so only emit a warning. - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -1741,7 +1741,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { Target::ForeignStatic => "static", _ => unreachable!(), }; - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -1751,7 +1751,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { _ => { // FIXME: #[no_mangle] was previously allowed on non-functions/statics and some // crates used this, so only emit a warning. - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -1929,7 +1929,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { return false; })) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( CONFLICTING_REPR_HINTS, hir_id, hint_spans.collect::>(), @@ -2171,7 +2171,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { fn check_deprecated(&self, hir_id: HirId, attr: &Attribute, _span: Span, target: Target) { match target { Target::Closure | Target::Expression | Target::Statement | Target::Arm => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -2187,7 +2187,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { match target { Target::ExternCrate | Target::Mod => {} _ => { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -2199,7 +2199,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { fn check_macro_export(&self, hir_id: HirId, attr: &Attribute, target: Target) { if target != Target::MacroDef { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -2209,7 +2209,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { && !meta_item_list.is_empty() { if meta_item_list.len() > 1 { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_MACRO_EXPORT_ARGUMENTS, hir_id, attr.span, @@ -2217,7 +2217,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { ); } else { if meta_item_list[0].name_or_empty() != sym::local_inner_macros { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INVALID_MACRO_EXPORT_ARGUMENTS, hir_id, meta_item_list[0].span(), @@ -2234,7 +2234,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { let is_decl_macro = !macro_definition.macro_rules; if is_decl_macro { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -2276,7 +2276,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { return; }; - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -2609,7 +2609,7 @@ fn check_duplicates( } else { (attr.span, *entry.get()) }; - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, this, diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index d7f17ac4547ab..d3909ce3a1c1c 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -199,7 +199,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { && !assign.span.from_expansion() { let is_field_assign = matches!(lhs.kind, hir::ExprKind::Field(..)); - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( lint::builtin::DEAD_CODE, assign.hir_id, assign.span, @@ -899,7 +899,7 @@ impl<'tcx> DeadVisitor<'tcx> { }; let hir_id = tcx.local_def_id_to_hir_id(first_item.def_id); - self.tcx.emit_spanned_lint(DEAD_CODE, hir_id, MultiSpan::from_spans(spans), diag); + self.tcx.emit_node_span_lint(DEAD_CODE, hir_id, MultiSpan::from_spans(spans), diag); } fn warn_multiple( diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 92687c705aee6..99f8186d5543b 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -1285,7 +1285,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // that we do not emit the same warning twice if the uninhabited type // is indeed `!`. - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNREACHABLE_CODE, expr_id, expr_span, @@ -1446,7 +1446,7 @@ impl<'tcx> Liveness<'_, 'tcx> { if self.used_on_entry(entry_ln, var) { if !self.live_on_entry(entry_ln, var) { if let Some(name) = self.should_warn(var) { - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_ASSIGNMENTS, var_hir_id, vec![span], @@ -1456,7 +1456,7 @@ impl<'tcx> Liveness<'_, 'tcx> { } } else { if let Some(name) = self.should_warn(var) { - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, var_hir_id, vec![span], @@ -1478,7 +1478,7 @@ impl<'tcx> Liveness<'_, 'tcx> { if !self.live_on_entry(ln, var) && let Some(name) = self.should_warn(var) { - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_ASSIGNMENTS, hir_id, spans, @@ -1552,7 +1552,7 @@ impl<'tcx> Liveness<'_, 'tcx> { if ln == self.exit_ln { false } else { self.assigned_on_exit(ln, var) }; if is_assigned { - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, first_hir_id, hir_ids_and_spans @@ -1574,7 +1574,7 @@ impl<'tcx> Liveness<'_, 'tcx> { span.with_hi(BytePos(span.hi().0 + 1)) }) .collect(); - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, first_hir_id, hir_ids_and_spans.iter().map(|(_, pat_span, _)| *pat_span).collect::>(), @@ -1599,7 +1599,7 @@ impl<'tcx> Liveness<'_, 'tcx> { let non_shorthands = non_shorthands.into_iter().map(|(_, pat_span, _)| pat_span).collect(); - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, first_hir_id, hir_ids_and_spans @@ -1638,7 +1638,7 @@ impl<'tcx> Liveness<'_, 'tcx> { } }; - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, first_hir_id, hir_ids_and_spans @@ -1690,7 +1690,7 @@ impl<'tcx> Liveness<'_, 'tcx> { if !self.live_on_exit(ln, var) && let Some(name) = self.should_warn(var) { - self.ir.tcx.emit_spanned_lint( + self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_ASSIGNMENTS, hir_id, spans, diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index d2cfdb7bf4774..0455d6d4acba3 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -70,7 +70,7 @@ fn check_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, abi: Abi) { if abi == Abi::Rust { let hir_id = tcx.local_def_id_to_hir_id(def_id); let span = tcx.def_span(def_id); - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNDEFINED_NAKED_FUNCTION_ABI, hir_id, span, diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 18b9ba0f042df..c1fe8c2133b75 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -122,7 +122,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { if matches!(kind, AnnotationKind::Prohibited | AnnotationKind::DeprecationProhibited) { let hir_id = self.tcx.local_def_id_to_hir_id(def_id); - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( USELESS_DEPRECATED, hir_id, *span, @@ -739,7 +739,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> { // do not lint when the trait isn't resolved, since resolution error should // be fixed first if t.path.res != Res::Err && c.fully_stable { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( INEFFECTIVE_UNSTABLE_TRAIT_IMPL, item.hir_id(), span, @@ -1073,7 +1073,7 @@ fn unnecessary_partially_stable_feature_lint( implies: Symbol, since: Symbol, ) { - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, @@ -1096,7 +1096,7 @@ fn unnecessary_stable_feature_lint( if since.as_str() == VERSION_PLACEHOLDER { since = sym::env_CFG_RELEASE; } - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, diff --git a/compiler/rustc_pattern_analysis/src/lints.rs b/compiler/rustc_pattern_analysis/src/lints.rs index f9f065fbe8b1e..4bfe7dfb072c4 100644 --- a/compiler/rustc_pattern_analysis/src/lints.rs +++ b/compiler/rustc_pattern_analysis/src/lints.rs @@ -158,7 +158,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>( // is not exhaustive enough. // // NB: The partner lint for structs lives in `compiler/rustc_hir_analysis/src/check/pat.rs`. - rcx.tcx.emit_spanned_lint( + rcx.tcx.emit_node_span_lint( NON_EXHAUSTIVE_OMITTED_PATTERNS, rcx.match_lint_level, rcx.scrut_span, diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 27b2580242716..d8c3c010a2a93 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -1001,7 +1001,7 @@ impl<'p, 'tcx> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> { .map(|span| errors::Overlap { range: overlap_as_pat.clone(), span }) .collect(); let pat_span = pat.data().unwrap().span; - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( lint::builtin::OVERLAPPING_RANGE_ENDPOINTS, self.match_lint_level, pat_span, diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 519303fc3aa96..0d4ee1e8dcaad 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -1399,7 +1399,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> { fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool { if self.leaks_private_dep(def_id) { - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( lint::builtin::EXPORTED_PRIVATE_DEPENDENCIES, self.tcx.local_def_id_to_hir_id(self.item_def_id), self.tcx.def_span(self.item_def_id.to_def_id()), @@ -1456,7 +1456,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> { } else { lint::builtin::PRIVATE_BOUNDS }; - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( lint, self.tcx.local_def_id_to_hir_id(self.item_def_id), span, @@ -1543,7 +1543,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> { if reachable_at_vis.is_public() && reexported_at_vis != reachable_at_vis { let hir_id = self.tcx.local_def_id_to_hir_id(def_id); let span = self.tcx.def_span(def_id.to_def_id()); - self.tcx.emit_spanned_lint( + self.tcx.emit_node_span_lint( lint::builtin::UNNAMEABLE_TYPES, hir_id, span, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 532e2cb36e3cc..bb1b6ec139023 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -359,7 +359,7 @@ impl IgnoredDiagnosticOption { option_name: &'static str, ) { if let (Some(new_item), Some(old_item)) = (new, old) { - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, tcx.local_def_id_to_hir_id(item_def_id.expect_local()), new_item, @@ -491,7 +491,7 @@ impl<'tcx> OnUnimplementedDirective { } if is_diagnostic_namespace_variant { - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, tcx.local_def_id_to_hir_id(item_def_id.expect_local()), vec![item.span()], @@ -629,7 +629,7 @@ impl<'tcx> OnUnimplementedDirective { AttrArgs::Eq(span, AttrArgsEq::Hir(expr)) => span.to(expr.span), }; - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, tcx.local_def_id_to_hir_id(item_def_id.expect_local()), report_span, @@ -640,14 +640,14 @@ impl<'tcx> OnUnimplementedDirective { } else if is_diagnostic_namespace_variant { match &attr.kind { AttrKind::Normal(p) if !matches!(p.item.args, AttrArgs::Empty) => { - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, tcx.local_def_id_to_hir_id(item_def_id.expect_local()), attr.span, MalformedOnUnimplementedAttrLint::new(attr.span), ); } - _ => tcx.emit_spanned_lint( + _ => tcx.emit_node_span_lint( UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, tcx.local_def_id_to_hir_id(item_def_id.expect_local()), attr.span, @@ -776,7 +776,7 @@ impl<'tcx> OnUnimplementedFormatString { s if generics.params.iter().any(|param| param.name == s) => (), s => { if self.is_diagnostic_namespace_variant { - tcx.emit_spanned_lint( + tcx.emit_node_span_lint( UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, tcx.local_def_id_to_hir_id(item_def_id.expect_local()), self.span, From 15a4c4fc6f1bda15bbc6c40395ff709d1b7fd166 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 16 Jan 2024 16:42:00 +1100 Subject: [PATCH 11/11] Rename `struct_lint_level` as `lint_level`. --- compiler/rustc_lint/src/context.rs | 8 ++++---- compiler/rustc_lint/src/levels.rs | 12 ++++++------ compiler/rustc_middle/src/lint.rs | 6 +++--- compiler/rustc_middle/src/ty/context.rs | 12 ++++++------ compiler/rustc_session/src/parse.rs | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 163507c1d50b5..04201a38c35ea 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -530,7 +530,7 @@ pub trait LintContext { /// Emit a lint at the appropriate level, with an optional associated span and an existing /// diagnostic. /// - /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature + /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature #[rustc_lint_diagnostics] fn span_lint_with_diagnostics( &self, @@ -553,7 +553,7 @@ pub trait LintContext { // set the span in their `decorate` function (preferably using set_span). /// Emit a lint at the appropriate level, with an optional associated span. /// - /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature + /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature #[rustc_lint_diagnostics] fn opt_span_lint>( &self, @@ -578,7 +578,7 @@ pub trait LintContext { /// Emit a lint at the appropriate level, with an associated span. /// - /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature + /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature #[rustc_lint_diagnostics] fn span_lint>( &self, @@ -600,7 +600,7 @@ pub trait LintContext { /// Emit a lint at the appropriate level, with no associated span. /// - /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature + /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature #[rustc_lint_diagnostics] fn lint( &self, diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 41b6245ae0d1e..d37f0c151714d 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -24,7 +24,7 @@ use rustc_hir::HirId; use rustc_index::IndexVec; use rustc_middle::hir::nested_filter; use rustc_middle::lint::{ - reveal_actual_level, struct_lint_level, LevelAndSource, LintExpectation, LintLevelSource, + lint_level, reveal_actual_level, LevelAndSource, LintExpectation, LintLevelSource, ShallowLintLevelMap, }; use rustc_middle::query::Providers; @@ -1062,7 +1062,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { if self.lint_added_lints { let lint = builtin::UNKNOWN_LINTS; let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS); - struct_lint_level( + lint_level( self.sess, lint, level, @@ -1096,7 +1096,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { /// Used to emit a lint-related diagnostic based on the current state of /// this lint context. /// - /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature + /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature #[rustc_lint_diagnostics] #[track_caller] pub(crate) fn opt_span_lint( @@ -1107,7 +1107,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), ) { let (level, src) = self.lint_level(lint); - struct_lint_level(self.sess, lint, level, src, span, msg, decorate) + lint_level(self.sess, lint, level, src, span, msg, decorate) } #[track_caller] @@ -1118,7 +1118,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { decorate: impl for<'a> DecorateLint<'a, ()>, ) { let (level, src) = self.lint_level(lint); - struct_lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| { + lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| { decorate.decorate_lint(lint); }); } @@ -1126,7 +1126,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { #[track_caller] pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> DecorateLint<'a, ()>) { let (level, src) = self.lint_level(lint); - struct_lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| { + lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| { decorate.decorate_lint(lint); }); } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index c545300cb8080..6ffa0819f3571 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -258,7 +258,7 @@ pub fn explain_lint_level_source( /// It is not intended to call `emit`/`cancel` on the `DiagnosticBuilder` passed /// in the `decorate` callback. #[track_caller] -pub fn struct_lint_level( +pub fn lint_level( sess: &Session, lint: &'static Lint, level: Level, @@ -270,7 +270,7 @@ pub fn struct_lint_level( // Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to // the "real" work. #[track_caller] - fn struct_lint_level_impl( + fn lint_level_impl( sess: &Session, lint: &'static Lint, level: Level, @@ -399,7 +399,7 @@ pub fn struct_lint_level( explain_lint_level_source(lint, level, src, &mut *err); err.emit() } - struct_lint_level_impl(sess, lint, level, src, span, msg, Box::new(decorate)) + lint_level_impl(sess, lint, level, src, span, msg, Box::new(decorate)) } /// Returns whether `span` originates in a foreign crate's external macro. diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index cd3a899a5f41b..0d53870a0baf0 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -7,7 +7,7 @@ pub mod tls; use crate::arena::Arena; use crate::dep_graph::{DepGraph, DepKindStruct}; use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos}; -use crate::lint::struct_lint_level; +use crate::lint::lint_level; use crate::metadata::ModChild; use crate::middle::codegen_fn_attrs::CodegenFnAttrs; use crate::middle::resolve_bound_vars; @@ -2086,14 +2086,14 @@ impl<'tcx> TyCtxt<'tcx> { ) { let msg = decorator.msg(); let (level, src) = self.lint_level_at_node(lint, hir_id); - struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg, |diag| { + lint_level(self.sess, lint, level, src, Some(span.into()), msg, |diag| { decorator.decorate_lint(diag); }) } /// Emit a lint at the appropriate level for a hir node, with an associated span. /// - /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature + /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature #[rustc_lint_diagnostics] #[track_caller] pub fn node_span_lint( @@ -2105,7 +2105,7 @@ impl<'tcx> TyCtxt<'tcx> { decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), ) { let (level, src) = self.lint_level_at_node(lint, hir_id); - struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate); + lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate); } /// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically @@ -2124,7 +2124,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Emit a lint at the appropriate level for a hir node. /// - /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature + /// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature #[rustc_lint_diagnostics] #[track_caller] pub fn node_lint( @@ -2135,7 +2135,7 @@ impl<'tcx> TyCtxt<'tcx> { decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), ) { let (level, src) = self.lint_level_at_node(lint, id); - struct_lint_level(self.sess, lint, level, src, None, msg, decorate); + lint_level(self.sess, lint, level, src, None, msg, decorate); } pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> { diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 16036e5be38c7..1cfaa49401dac 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -144,7 +144,7 @@ pub fn feature_warn_issue( let mut err = sess.parse_sess.dcx.struct_span_warn(span, explain); add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false); - // Decorate this as a future-incompatibility lint as in rustc_middle::lint::struct_lint_level + // Decorate this as a future-incompatibility lint as in rustc_middle::lint::lint_level let lint = UNSTABLE_SYNTAX_PRE_EXPANSION; let future_incompatible = lint.future_incompatible.as_ref().unwrap(); err.is_lint(lint.name_lower(), /* has_future_breakage */ false);