From 2bb3b01af24afd90157660cb64de891699de20d8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 24 Feb 2026 15:47:11 +0100 Subject: [PATCH] Replace `TyCtxt::emit_node_span_lint` with `emit_diag_node_span_lint` --- compiler/rustc_borrowck/src/lib.rs | 7 +- .../rustc_codegen_ssa/src/target_features.rs | 2 +- .../rustc_const_eval/src/const_eval/error.rs | 2 +- .../src/const_eval/machine.rs | 2 +- .../rustc_hir_analysis/src/check/check.rs | 2 +- .../src/check/compare_impl_item/refine.rs | 4 +- .../rustc_hir_analysis/src/check/wfcheck.rs | 4 +- .../src/coherence/orphan.rs | 4 +- .../src/hir_ty_lowering/dyn_trait.rs | 2 +- compiler/rustc_hir_typeck/src/cast.rs | 6 +- compiler/rustc_hir_typeck/src/fallback.rs | 4 +- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- .../rustc_hir_typeck/src/method/confirm.rs | 2 +- compiler/rustc_lint/src/async_closures.rs | 2 +- compiler/rustc_lint/src/async_fn_in_trait.rs | 2 +- compiler/rustc_lint/src/dangling.rs | 4 +- compiler/rustc_lint/src/expect.rs | 2 +- compiler/rustc_lint/src/foreign_modules.rs | 2 +- .../src/function_cast_as_integer.rs | 2 +- compiler/rustc_lint/src/gpukernel_abi.rs | 2 +- compiler/rustc_lint/src/if_let_rescope.rs | 2 +- .../rustc_lint/src/impl_trait_overcaptures.rs | 4 +- compiler/rustc_lint/src/transmute.rs | 4 +- compiler/rustc_middle/src/middle/stability.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 18 +---- compiler/rustc_mir_build/src/builder/mod.rs | 2 +- .../rustc_mir_build/src/check_unsafety.rs | 73 +++++++++---------- .../src/thir/pattern/check_match.rs | 6 +- .../src/check_call_recursion.rs | 2 +- .../src/check_const_item_mutation.rs | 4 +- compiler/rustc_mir_transform/src/coroutine.rs | 2 +- .../src/ffi_unwind_calls.rs | 4 +- .../src/function_item_references.rs | 2 +- .../src/known_panics_lint.rs | 2 +- .../src/lint_tail_expr_drop_order.rs | 2 +- compiler/rustc_mir_transform/src/liveness.rs | 12 +-- .../src/mono_checks/move_check.rs | 2 +- compiler/rustc_passes/src/check_attr.rs | 40 +++++----- compiler/rustc_passes/src/dead.rs | 4 +- compiler/rustc_passes/src/stability.rs | 8 +- compiler/rustc_pattern_analysis/src/lints.rs | 2 +- compiler/rustc_pattern_analysis/src/rustc.rs | 6 +- compiler/rustc_privacy/src/lib.rs | 6 +- 43 files changed, 123 insertions(+), 145 deletions(-) diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 259c6cd7728c..2fc057ae3882 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -2698,12 +2698,7 @@ fn lint_unused_mut(&self) { let mut_span = tcx.sess.source_map().span_until_non_whitespace(span); - tcx.emit_diag_node_span_lint( - UNUSED_MUT, - lint_root, - span, - VarNeedNotMut { span: mut_span }, - ) + tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span }) } } } diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index d7f871527e3d..e9209657984e 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -75,7 +75,7 @@ pub(crate) fn from_target_feature_attr( // For "neon" specifically, we emit an FCW instead of a hard error. // See . if tcx.sess.target.arch == Arch::AArch64 && name.as_str() == "neon" { - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( AARCH64_SOFTFLOAT_NEON, tcx.local_def_id_to_hir_id(did), feature_span, diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index 7efef74e70aa..6694a6e8ae40 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -256,5 +256,5 @@ pub(super) fn lint<'tcx, L>( { let (span, frames) = get_span_and_frames(tcx, &machine.stack); - tcx.emit_diag_node_span_lint(lint, machine.best_lint_scope(*tcx), span, decorator(frames)); + tcx.emit_node_span_lint(lint, machine.best_lint_scope(*tcx), span, decorator(frames)); } diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 3da9f2e2cdcd..c2b3ea19c3f4 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -718,7 +718,7 @@ fn increment_const_eval_counter(ecx: &mut InterpCx<'tcx, Self>) -> InterpResult< .level .is_error(); let span = ecx.cur_span(); - ecx.tcx.emit_diag_node_span_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/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index a6a1b95ce4c1..2068fc0ab978 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1256,7 +1256,7 @@ fn check_impl_items_against_trait<'tcx>( } if self_is_guaranteed_unsize_self && tcx.generics_require_sized_self(ty_trait_item.def_id) { - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( rustc_lint_defs::builtin::DEAD_CODE, tcx.local_def_id_to_hir_id(ty_impl_item.def_id.expect_local()), tcx.def_span(ty_impl_item.def_id), 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 0944edd86ef1..31104411ab55 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 @@ -345,7 +345,7 @@ fn report_mismatched_rpitit_signature<'tcx>( with_no_trimmed_paths!(with_types_for_signature!(format!("{return_ty}"))); let span = unmatched_bound.unwrap_or(span); - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE }, tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()), span, @@ -442,7 +442,7 @@ fn report_mismatched_rpitit_captures<'tcx>( .sort_by_cached_key(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_))); let suggestion = format!("use<{}>", trait_captured_args.iter().join(", ")); - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE }, tcx.local_def_id_to_hir_id(impl_opaque_def_id), use_bound_span, diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 5a4d1794623f..426331b33bd9 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -797,7 +797,7 @@ fn lint_item_shadowing_supertrait_item<'tcx>(tcx: TyCtxt<'tcx>, trait_item_def_i errors::SupertraitItemShadowee::Several { traits: traits.into(), spans: spans.into() } }; - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( SHADOWING_SUPERTRAIT_ITEMS, tcx.local_def_id_to_hir_id(trait_item_def_id), tcx.def_span(trait_item_def_id), @@ -2458,7 +2458,7 @@ fn lint_redundant_lifetimes<'tcx>( && outlives_env.free_region_map().sub_free_regions(tcx, victim, candidate) { shadowed.insert(victim); - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( rustc_lint_defs::builtin::REDUNDANT_LIFETIMES, tcx.local_def_id_to_hir_id(def_id.expect_local()), tcx.def_span(def_id), diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index b5e40058e753..f1e138dbcb97 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -497,13 +497,13 @@ fn lint_uncovered_ty_params<'tcx>( let name = tcx.item_ident(param_def_id); match local_ty { - Some(local_type) => tcx.emit_diag_node_span_lint( + Some(local_type) => tcx.emit_node_span_lint( UNCOVERED_PARAM_IN_PROJECTION, hir_id, span, errors::TyParamFirstLocalLint { span, note: (), param: name, local_type }, ), - None => tcx.emit_diag_node_span_lint( + None => tcx.emit_node_span_lint( UNCOVERED_PARAM_IN_PROJECTION, hir_id, span, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs index 459d13e46e85..7b8e09943df7 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs @@ -291,7 +291,7 @@ pub(super) fn lower_trait_object_ty( // FIXME(mgca): Ideally we would generalize the name of this lint to sth. like // `unused_associated_item_bindings` since this can now also trigger on *const* // projections / assoc *const* bindings. - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( UNUSED_ASSOCIATED_TYPE_BOUNDS, hir_id, span, diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index af529386eee2..eaa87f1d4cbc 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -687,7 +687,7 @@ fn trivial_cast_lint(&self, fcx: &FnCtxt<'a, '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_diag_node_span_lint( + fcx.tcx.emit_node_span_lint( lint, self.expr.hir_id, self.span, @@ -1125,7 +1125,7 @@ fn lossy_provenance_ptr2int_lint(&self, fcx: &FnCtxt<'a, 'tcx>, t_c: ty::cast::I }; let lint = errors::LossyProvenancePtr2Int { expr_ty, cast_ty, sugg }; - fcx.tcx.emit_diag_node_span_lint( + fcx.tcx.emit_node_span_lint( lint::builtin::LOSSY_PROVENANCE_CASTS, self.expr.hir_id, self.span, @@ -1141,7 +1141,7 @@ fn fuzzy_provenance_int2ptr_lint(&self, fcx: &FnCtxt<'a, '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_diag_node_span_lint( + fcx.tcx.emit_node_span_lint( lint::builtin::FUZZY_PROVENANCE_CASTS, self.expr.hir_id, self.span, diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs index 79fdfd356367..c10e7f3bfb8b 100644 --- a/compiler/rustc_hir_typeck/src/fallback.rs +++ b/compiler/rustc_hir_typeck/src/fallback.rs @@ -238,7 +238,7 @@ fn lint_never_type_fallback_flowing_into_unsafe_code( let sugg = self.try_to_suggest_annotations(&[root_vid], coercion_graph); for (hir_id, span, reason) in affected_unsafe_infer_vars { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE, hir_id, span, @@ -304,7 +304,7 @@ fn lint_obligations_broken_by_never_type_fallback_change( { self.adjust_fulfillment_error_for_expr_obligation(never_error); let sugg = self.try_to_suggest_annotations(diverging_vids, coercions); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, self.tcx.local_def_id_to_hir_id(self.body_id), self.tcx.def_span(self.body_id), diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 81523cdf633d..1931222bba30 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1145,7 +1145,7 @@ pub(crate) fn instantiate_value_path( }); return (Ty::new_error(self.tcx, guar), res); } else { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( SELF_CONSTRUCTOR_FROM_OUTER_ITEM, hir_id, path_span, diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 6e5b05a8191f..608bc7dffd9c 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -717,7 +717,7 @@ fn lint_shadowed_supertrait_items( SupertraitItemShadowee::Several { traits: traits.into(), spans: spans.into() } }; - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS, segment.hir_id, segment.ident.span, diff --git a/compiler/rustc_lint/src/async_closures.rs b/compiler/rustc_lint/src/async_closures.rs index ebcafa2ad5cd..0bc245c742b2 100644 --- a/compiler/rustc_lint/src/async_closures.rs +++ b/compiler/rustc_lint/src/async_closures.rs @@ -92,7 +92,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { let deletion_span = cx.tcx.sess.source_map().span_extend_while_whitespace(async_decl_span); - cx.tcx.emit_diag_node_span_lint( + cx.tcx.emit_node_span_lint( CLOSURE_RETURNING_ASYNC_BLOCK, expr.hir_id, fn_decl_span, diff --git a/compiler/rustc_lint/src/async_fn_in_trait.rs b/compiler/rustc_lint/src/async_fn_in_trait.rs index 19d0a13690db..9923f05df3c7 100644 --- a/compiler/rustc_lint/src/async_fn_in_trait.rs +++ b/compiler/rustc_lint/src/async_fn_in_trait.rs @@ -118,7 +118,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitIte opaq_def.def_id, " + Send", ); - cx.tcx.emit_diag_node_span_lint( + cx.tcx.emit_node_span_lint( ASYNC_FN_IN_TRAIT, item.hir_id(), async_span, diff --git a/compiler/rustc_lint/src/dangling.rs b/compiler/rustc_lint/src/dangling.rs index 668f2741bb0a..448c0ded637c 100644 --- a/compiler/rustc_lint/src/dangling.rs +++ b/compiler/rustc_lint/src/dangling.rs @@ -186,7 +186,7 @@ fn lint_addr_of_local<'a>( && let Res::Local(from) = cx.qpath_res(qpath, inner_of.hir_id) && cx.tcx.hir_enclosing_body_owner(from) == dcx.body { - cx.tcx.emit_diag_node_span_lint( + cx.tcx.emit_node_span_lint( DANGLING_POINTERS_FROM_LOCALS, expr.hir_id, expr.span, @@ -270,7 +270,7 @@ fn lint_expr(cx: &LateContext<'_>, expr: &Expr<'_>) { && find_attr!(cx.tcx, fn_id, RustcAsPtr(_)) { // FIXME: use `emit_node_lint` when `#[primary_span]` is added. - cx.tcx.emit_diag_node_span_lint( + cx.tcx.emit_node_span_lint( DANGLING_POINTERS_FROM_TEMPORARIES, expr.hir_id, method.ident.span, diff --git a/compiler/rustc_lint/src/expect.rs b/compiler/rustc_lint/src/expect.rs index b7c8ff640871..481e116d06e0 100644 --- a/compiler/rustc_lint/src/expect.rs +++ b/compiler/rustc_lint/src/expect.rs @@ -61,7 +61,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option) { { let rationale = expectation.reason.map(|rationale| ExpectationNote { rationale }); let note = expectation.is_unfulfilled_lint_expectations; - tcx.emit_diag_node_span_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 b9ae354c7e18..d234c6863103 100644 --- a/compiler/rustc_lint/src/foreign_modules.rs +++ b/compiler/rustc_lint/src/foreign_modules.rs @@ -162,7 +162,7 @@ fn check_foreign_item<'tcx>(&mut self, tcx: TyCtxt<'tcx>, this_fi: hir::ForeignI sub, } }; - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( CLASHING_EXTERN_DECLARATIONS, this_fi.hir_id(), mismatch_label, diff --git a/compiler/rustc_lint/src/function_cast_as_integer.rs b/compiler/rustc_lint/src/function_cast_as_integer.rs index 9b530ec5568c..2a4ff1f63db5 100644 --- a/compiler/rustc_lint/src/function_cast_as_integer.rs +++ b/compiler/rustc_lint/src/function_cast_as_integer.rs @@ -47,7 +47,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { } let cast_from_ty = cx.typeck_results().expr_ty(cast_from_expr); if matches!(cast_from_ty.kind(), ty::FnDef(..)) { - cx.tcx.emit_diag_node_span_lint( + cx.tcx.emit_node_span_lint( FUNCTION_CASTS_AS_INTEGER, expr.hir_id, cast_to_expr.span.with_lo(cast_from_expr.span.hi() + BytePos(1)), diff --git a/compiler/rustc_lint/src/gpukernel_abi.rs b/compiler/rustc_lint/src/gpukernel_abi.rs index d8c8feda94ae..4fb26739cd28 100644 --- a/compiler/rustc_lint/src/gpukernel_abi.rs +++ b/compiler/rustc_lint/src/gpukernel_abi.rs @@ -173,7 +173,7 @@ fn check_fn( let mut checker = CheckGpuKernelTypes { tcx: cx.tcx, has_invalid: false }; input_ty.fold_with(&mut checker); if checker.has_invalid { - cx.tcx.emit_diag_node_span_lint( + cx.tcx.emit_node_span_lint( IMPROPER_GPU_KERNEL_ARG, input_hir.hir_id, input_hir.span, diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 43c51240aa33..ba196ef301c0 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -238,7 +238,7 @@ fn probe_if_cascade<'tcx>(&mut self, cx: &LateContext<'tcx>, mut expr: &'tcx hir } } if let Some((span, hir_id)) = first_if_to_lint { - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( IF_LET_RESCOPE, hir_id, span, diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index eb904e1bc819..3e18e918439c 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -345,7 +345,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) { .map(|(&def_id, _)| self.tcx.def_span(def_id)) .collect(); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( IMPL_TRAIT_OVERCAPTURES, self.tcx.local_def_id_to_hir_id(opaque_def_id), opaque_span, @@ -402,7 +402,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) { .iter() .all(|(def_id, _)| explicitly_captured.contains(def_id)) { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( IMPL_TRAIT_REDUNDANT_CAPTURES, self.tcx.local_def_id_to_hir_id(opaque_def_id), opaque_span, diff --git a/compiler/rustc_lint/src/transmute.rs b/compiler/rustc_lint/src/transmute.rs index 7a8df8195a0e..b55d209130b0 100644 --- a/compiler/rustc_lint/src/transmute.rs +++ b/compiler/rustc_lint/src/transmute.rs @@ -166,7 +166,7 @@ fn check_int_to_ptr_transmute<'tcx>( } let suffix = if mutbl.is_mut() { "_mut" } else { "" }; - cx.tcx.emit_diag_node_span_lint( + cx.tcx.emit_node_span_lint( INTEGER_TO_PTR_TRANSMUTES, expr.hir_id, expr.span, @@ -219,7 +219,7 @@ fn check_ptr_transmute_in_const<'tcx>( || matches!(cx.tcx.def_kind(body_owner_def_id), DefKind::AssocConst) { if src.is_raw_ptr() && dst.is_integral() { - cx.tcx.emit_diag_node_span_lint( + cx.tcx.emit_node_span_lint( PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS, expr.hir_id, expr.span, diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index bd0fad55bc0f..ff6baabbb29a 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -257,7 +257,7 @@ fn late_report_deprecation( note: depr.note.map(|ident| ident.name), since_kind: deprecated_since_kind(is_in_effect, depr.since), }; - tcx.emit_diag_node_span_lint(lint, hir_id, method_span, diag); + tcx.emit_node_span_lint(lint, hir_id, method_span, diag); } /// Result of `TyCtxt::eval_stability`. diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9eb41e57d4dc..d21f07a23e32 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2495,26 +2495,10 @@ pub fn mk_outlives_from_iter(self, iter: I) -> T::Output T::collect_and_apply(iter, |xs| self.mk_outlives(xs)) } - /// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`, - /// typically generated by `#[derive(LintDiagnostic)]`). - #[track_caller] - pub fn emit_node_span_lint( - self, - lint: &'static Lint, - hir_id: HirId, - span: impl Into, - decorator: impl for<'a> LintDiagnostic<'a, ()>, - ) { - let level = self.lint_level_at_node(lint, hir_id); - lint_level(self.sess, lint, level, Some(span.into()), |lint| { - decorator.decorate_lint(lint); - }) - } - /// Emit a lint at `span` from a lint struct (some type that implements `Diagnostic`, /// typically generated by `#[derive(Diagnostic)]`). #[track_caller] - pub fn emit_diag_node_span_lint( + pub fn emit_node_span_lint( self, lint: &'static Lint, hir_id: HirId, diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index 383581157174..c8ca7bfccc07 100644 --- a/compiler/rustc_mir_build/src/builder/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -921,7 +921,7 @@ fn find_unreachable_code_from( .as_ref() .unwrap_crate_local() .lint_root; - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::UNREACHABLE_CODE, lint_root, target_loc.span, diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index e3fa4802518a..24c85b7ec3f5 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -108,7 +108,7 @@ fn emit_deprecated_safe_fn_call(&self, span: Span, kind: &UnsafeOpKind) -> bool }) .unwrap_or_default(); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( DEPRECATED_SAFE_2024, self.hir_context, span, @@ -780,7 +780,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( // 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_diag_node_span_lint( + CallToUnsafeFunction(Some(did)) => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -790,7 +790,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - CallToUnsafeFunction(None) => tcx.emit_diag_node_span_lint( + CallToUnsafeFunction(None) => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -799,7 +799,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - UseOfInlineAssembly => tcx.emit_diag_node_span_lint( + UseOfInlineAssembly => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -808,7 +808,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - InitializingTypeWith => tcx.emit_diag_node_span_lint( + InitializingTypeWith => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -817,7 +817,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - InitializingTypeWithUnsafeField => tcx.emit_diag_node_span_lint( + InitializingTypeWithUnsafeField => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -826,7 +826,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - UseOfMutableStatic => tcx.emit_diag_node_span_lint( + UseOfMutableStatic => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -835,7 +835,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - UseOfExternStatic => tcx.emit_diag_node_span_lint( + UseOfExternStatic => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -844,7 +844,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - UseOfUnsafeField => tcx.emit_diag_node_span_lint( + UseOfUnsafeField => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -853,7 +853,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - DerefOfRawPointer => tcx.emit_diag_node_span_lint( + DerefOfRawPointer => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -862,7 +862,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - AccessToUnionField => tcx.emit_diag_node_span_lint( + AccessToUnionField => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -871,7 +871,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - MutationOfLayoutConstrainedField => tcx.emit_diag_node_span_lint( + MutationOfLayoutConstrainedField => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -880,7 +880,7 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - BorrowOfLayoutConstrainedField => tcx.emit_diag_node_span_lint( + BorrowOfLayoutConstrainedField => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -889,30 +889,29 @@ fn emit_unsafe_op_in_unsafe_fn_lint( unsafe_not_inherited_note, }, ), - CallToFunctionWith { function, missing, build_enabled } => tcx - .emit_diag_node_span_lint( - UNSAFE_OP_IN_UNSAFE_FN, - hir_id, + CallToFunctionWith { function, missing, build_enabled } => tcx.emit_node_span_lint( + UNSAFE_OP_IN_UNSAFE_FN, + hir_id, + span, + UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe { span, - UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe { - span, - function: with_no_trimmed_paths!(tcx.def_path_str(*function)), - missing_target_features: DiagArgValue::StrListSepByAnd( - missing.iter().map(|feature| Cow::from(feature.to_string())).collect(), - ), - missing_target_features_count: missing.len(), - note: !build_enabled.is_empty(), - build_target_features: DiagArgValue::StrListSepByAnd( - build_enabled - .iter() - .map(|feature| Cow::from(feature.to_string())) - .collect(), - ), - build_target_features_count: build_enabled.len(), - unsafe_not_inherited_note, - }, - ), - UnsafeBinderCast => tcx.emit_diag_node_span_lint( + function: with_no_trimmed_paths!(tcx.def_path_str(*function)), + missing_target_features: DiagArgValue::StrListSepByAnd( + missing.iter().map(|feature| Cow::from(feature.to_string())).collect(), + ), + missing_target_features_count: missing.len(), + note: !build_enabled.is_empty(), + build_target_features: DiagArgValue::StrListSepByAnd( + build_enabled + .iter() + .map(|feature| Cow::from(feature.to_string())) + .collect(), + ), + build_target_features_count: build_enabled.len(), + unsafe_not_inherited_note, + }, + ), + UnsafeBinderCast => tcx.emit_node_span_lint( UNSAFE_OP_IN_UNSAFE_FN, hir_id, span, @@ -1201,7 +1200,7 @@ pub(crate) 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_diag_node_span_lint( + tcx.emit_node_span_lint( UNUSED_UNSAFE, hir_id, block_span, 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 5ebfd8000ef8..9231b425c4c3 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -797,7 +797,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_diag_node_span_lint( + cx.tcx.emit_node_span_lint( BINDINGS_WITH_VARIANT_NAME, cx.hir_source, pat.span, @@ -839,7 +839,7 @@ fn report_irrefutable_let_patterns( ) { macro_rules! emit_diag { ($lint:tt) => {{ - tcx.emit_diag_node_span_lint(IRREFUTABLE_LET_PATTERNS, id, span, $lint { count }); + tcx.emit_node_span_lint(IRREFUTABLE_LET_PATTERNS, id, span, $lint { count }); }}; } @@ -924,7 +924,7 @@ fn report_unreachable_pattern<'p, 'tcx>( lint.covered_by_many = Some(multispan); } } - cx.tcx.emit_diag_node_span_lint(UNREACHABLE_PATTERNS, hir_id, pat_span, lint); + cx.tcx.emit_node_span_lint(UNREACHABLE_PATTERNS, hir_id, pat_span, lint); } /// Detect typos that were meant to be a `const` but were interpreted as a new pattern binding. diff --git a/compiler/rustc_mir_transform/src/check_call_recursion.rs b/compiler/rustc_mir_transform/src/check_call_recursion.rs index baefeaa73047..cac6308617ac 100644 --- a/compiler/rustc_mir_transform/src/check_call_recursion.rs +++ b/compiler/rustc_mir_transform/src/check_call_recursion.rs @@ -83,7 +83,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_diag_node_span_lint( + tcx.emit_node_span_lint( UNCONDITIONAL_RECURSION, hir_id, sp, 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 20daa9179930..375db17fb73a 100644 --- a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs +++ b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs @@ -104,7 +104,7 @@ fn visit_statement(&mut self, stmt: &Statement<'tcx>, loc: Location) { && let Some((lint_root, span, item)) = self.should_lint_const_item_usage(lhs, def_id, loc) { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( CONST_ITEM_MUTATION, lint_root, span, @@ -150,7 +150,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, loc: Location) { if let Some((lint_root, span, item)) = self.should_lint_const_item_usage(place, def_id, lint_loc) { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( CONST_ITEM_MUTATION, lint_root, span, diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index 3d4e201a8f17..c83b10a5e583 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -1990,7 +1990,7 @@ fn check_must_not_suspend_def( if let Some(reason_str) = find_attr!(tcx, def_id, MustNotSupend {reason} => reason) { let reason = reason_str.map(|s| errors::MustNotSuspendReason { span: data.source_span, reason: s }); - tcx.emit_diag_node_span_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 2314864e17d5..06e7bf974b51 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -63,7 +63,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { .lint_root; let span = terminator.source_info.span; - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( FFI_UNWIND_CALLS, lint_root, span, @@ -115,7 +115,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_diag_node_span_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 7b35c18773fa..2ae8f43cf6c8 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -175,7 +175,7 @@ fn emit_lint( ret, ); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( FUNCTION_ITEM_REFERENCES, lint_root, span, diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index 9c3b67d43abf..873f6a01ec36 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -297,7 +297,7 @@ fn report_assert_as_lint( let source_info = self.body.source_info(location); if let Some(lint_root) = self.lint_root(*source_info) { let span = source_info.span; - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint_kind.lint(), lint_root, span, diff --git a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs index 17bd630be2d8..667a702e4056 100644 --- a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs +++ b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs @@ -451,7 +451,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body< } let span = local_labels[0].span; - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( lint::builtin::TAIL_EXPR_DROP_ORDER, lint_root.unwrap_or(CRATE_HIR_ID), span, diff --git a/compiler/rustc_mir_transform/src/liveness.rs b/compiler/rustc_mir_transform/src/liveness.rs index 0817022d5642..3fbe1e398a18 100644 --- a/compiler/rustc_mir_transform/src/liveness.rs +++ b/compiler/rustc_mir_transform/src/liveness.rs @@ -968,7 +968,7 @@ fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, _: Location) { let typo = maybe_suggest_typo(); errors::UnusedVariableSugg::TryPrefix { spans: vec![def_span], name, typo } }; - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, hir_id, def_span, @@ -1018,7 +1018,7 @@ fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, _: Location) { } let typo = maybe_suggest_typo(); - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, hir_id, def_span, @@ -1060,7 +1060,7 @@ fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, _: Location) { errors::UnusedVariableSugg::TryPrefix { name, typo, spans: vec![def_span] } }; - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, hir_id, spans, @@ -1126,20 +1126,20 @@ fn report_unused_assignments(self) { source_info.span, self.body, ); - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( lint::builtin::UNUSED_ASSIGNMENTS, hir_id, source_info.span, errors::UnusedAssign { name, help: suggestion.is_none(), suggestion }, ) } - AccessKind::Param => tcx.emit_diag_node_span_lint( + AccessKind::Param => tcx.emit_node_span_lint( lint::builtin::UNUSED_ASSIGNMENTS, hir_id, source_info.span, errors::UnusedAssignPassed { name }, ), - AccessKind::Capture => tcx.emit_diag_node_span_lint( + AccessKind::Capture => tcx.emit_node_span_lint( lint::builtin::UNUSED_ASSIGNMENTS, hir_id, decl_span, diff --git a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs index 12aa91851383..a8f3104c0d98 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs @@ -174,7 +174,7 @@ fn lint_large_assignment( } } - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( LARGE_ASSIGNMENTS, lint_root, reported_span, diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 27cfc7cb1a0e..d3a39909077b 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -453,7 +453,7 @@ fn check_attributes( .span_until_char(attr_span, '[') .shrink_to_hi(); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -464,7 +464,7 @@ fn check_attributes( }, ) } - ast::AttrStyle::Inner => self.tcx.emit_diag_node_span_lint( + ast::AttrStyle::Inner => self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span, @@ -595,7 +595,7 @@ fn check_do_not_recommend( if _impl.of_trait.is_none() ) { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( MISPLACED_DIAGNOSTIC_ATTRIBUTES, hir_id, attr_span, @@ -613,7 +613,7 @@ fn check_diagnostic_on_unimplemented( directive: Option<&Directive>, ) { if !matches!(target, Target::Trait) { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( MISPLACED_DIAGNOSTIC_ATTRIBUTES, hir_id, attr_span, @@ -639,7 +639,7 @@ fn check_diagnostic_on_unimplemented( } }); if !has_generic { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( MALFORMED_DIAGNOSTIC_FORMAT_LITERALS, hir_id, span, @@ -668,7 +668,7 @@ fn check_diagnostic_on_const( ItemLike::Item(it) => match it.expect_impl().constness { Constness::Const => { let item_span = self.tcx.hir_span(hir_id); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( MISPLACED_DIAGNOSTIC_ATTRIBUTES, hir_id, attr_span, @@ -682,7 +682,7 @@ fn check_diagnostic_on_const( } } let item_span = self.tcx.hir_span(hir_id); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( MISPLACED_DIAGNOSTIC_ATTRIBUTES, hir_id, attr_span, @@ -707,7 +707,7 @@ fn check_inline(&self, hir_id: HirId, attr_span: Span, kind: &InlineAttr, target let attrs = self.tcx.codegen_fn_attrs(did); // Not checking naked as `#[inline]` is forbidden for naked functions anyways. if attrs.contains_extern_indicator() { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr_span, @@ -1058,7 +1058,7 @@ fn check_doc_inline(&self, hir_id: HirId, target: Target, inline: &[(DocInline, match target { Target::Use | Target::ExternCrate => {} _ => { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, span, @@ -1073,7 +1073,7 @@ fn check_doc_inline(&self, hir_id: HirId, target: Target, inline: &[(DocInline, fn check_doc_masked(&self, span: Span, hir_id: HirId, target: Target) { if target != Target::ExternCrate { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, span, @@ -1086,7 +1086,7 @@ fn check_doc_masked(&self, span: Span, hir_id: HirId, target: Target) { } if self.tcx.extern_mod_stmt_cnum(hir_id.owner.def_id).is_none() { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, span, @@ -1238,7 +1238,7 @@ fn check_link(&self, hir_id: HirId, attr_span: Span, span: Span, target: Target) return; } - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr_span, @@ -1475,7 +1475,7 @@ fn check_repr( if let ItemLike::Item(item) = item { is_c_like_enum(item) } else { false } })) { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( CONFLICTING_REPR_HINTS, hir_id, hint_spans.collect::>(), @@ -1571,7 +1571,7 @@ fn check_deprecated(&self, hir_id: HirId, attr_span: Span, target: Target) { if self.tcx.def_kind(self.tcx.local_parent(hir_id.owner.def_id)) == DefKind::Impl { of_trait: true } => { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr_span, @@ -1592,7 +1592,7 @@ fn check_macro_export(&self, hir_id: HirId, attr_span: Span, target: Target) { let is_decl_macro = !macro_definition.macro_rules; if is_decl_macro { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr_span, @@ -1644,7 +1644,7 @@ fn check_unused_attribute(&self, hir_id: HirId, attr: &Attribute, style: Option< .span_until_char(attr_span, '[') .shrink_to_hi(); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr_span, @@ -1655,7 +1655,7 @@ fn check_unused_attribute(&self, hir_id: HirId, attr: &Attribute, style: Option< }, ) } - Some(ast::AttrStyle::Inner) | None => self.tcx.emit_diag_node_span_lint( + Some(ast::AttrStyle::Inner) | None => self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span(), @@ -1681,7 +1681,7 @@ fn check_unused_attribute(&self, hir_id: HirId, attr: &Attribute, style: Option< return; }; - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, attr.span(), @@ -1849,7 +1849,7 @@ fn check_mix_no_mangle_export(&self, hir_id: HirId, attrs: &[Attribute]) { "#[export_name]" }; - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::UNUSED_ATTRIBUTES, hir_id, no_mangle_span, @@ -2193,7 +2193,7 @@ fn check_duplicates( } else { (attr_span, *entry.get()) }; - tcx.emit_diag_node_span_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 0f5dd1ceda5b..f6d00f5342f2 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -232,7 +232,7 @@ fn check_for_self_assign_helper<'tcx>( && !assign.span.from_expansion() { let is_field_assign = matches!(lhs.kind, hir::ExprKind::Field(..)); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::DEAD_CODE, assign.hir_id, assign.span, @@ -1104,7 +1104,7 @@ fn lint_at_single_level( }; let hir_id = tcx.local_def_id_to_hir_id(first_item.def_id); - self.tcx.emit_diag_node_span_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/stability.rs b/compiler/rustc_passes/src/stability.rs index 927eb04cb55e..6fd28c78740c 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -642,7 +642,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { && c.fully_stable && !unstable_feature_bound_in_effect { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( INEFFECTIVE_UNSTABLE_TRAIT_IMPL, item.hir_id(), span, @@ -859,7 +859,7 @@ fn visit_path(&mut self, path: &hir::Path<'tcx>, id: hir::HirId) { note: Some(deprecation), since_kind: lint::DeprecatedSinceKind::InEffect, }; - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( DEPRECATED, id, method_span.unwrap_or(path.span), @@ -1130,7 +1130,7 @@ fn unnecessary_partially_stable_feature_lint( implies: Symbol, since: Symbol, ) { - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, @@ -1153,7 +1153,7 @@ fn unnecessary_stable_feature_lint( if since.as_str() == VERSION_PLACEHOLDER { since = sym::env_CFG_RELEASE; } - tcx.emit_diag_node_span_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 314d3e60f2a4..3da744dc8c02 100644 --- a/compiler/rustc_pattern_analysis/src/lints.rs +++ b/compiler/rustc_pattern_analysis/src/lints.rs @@ -74,7 +74,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'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_diag_node_span_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 2804a807b993..dc38f2d8bc70 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -948,7 +948,7 @@ fn lint_overlapping_range_endpoints( .map(|span| errors::Overlap { range: overlap_as_pat.to_string(), span }) .collect(); let pat_span = pat.data().span; - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::OVERLAPPING_RANGE_ENDPOINTS, self.match_lint_level, pat_span, @@ -984,7 +984,7 @@ fn lint_non_contiguous_range_endpoints( let gap_as_pat = self.print_pat_range(&gap, *pat.ty()); if gapped_with.is_empty() { // If `gapped_with` is empty, `gap == T::MAX`. - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::NON_CONTIGUOUS_RANGE_ENDPOINTS, self.match_lint_level, thir_pat.span, @@ -998,7 +998,7 @@ fn lint_non_contiguous_range_endpoints( }, ); } else { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::NON_CONTIGUOUS_RANGE_ENDPOINTS, self.match_lint_level, thir_pat.span, diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 87b128779737..59fd908756b0 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -1416,7 +1416,7 @@ fn trait_ref(&mut self) -> &mut Self { fn check_def_id(&self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool { if self.leaks_private_dep(def_id) { - self.tcx.emit_diag_node_span_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()), @@ -1475,7 +1475,7 @@ fn check_def_id(&self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> b }; let span = self.tcx.def_span(self.item_def_id.to_def_id()); let vis_span = self.tcx.def_span(def_id); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint, self.tcx.local_def_id_to_hir_id(self.item_def_id), span, @@ -1565,7 +1565,7 @@ fn check_unnameable(&self, def_id: LocalDefId, effective_vis: Option