Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0011fac

Browse files
committed
Auto merge of rust-lang#120017 - nnethercote:lint-api, r=oli-obk
Fix naming in the lint API Methods for emit lints are named very inconsistently. This PR fixes that up. r? `@compiler-errors`
2 parents d6b151f + 15a4c4f commit 0011fac

File tree

96 files changed

+353
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+353
-376
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ fn do_mir_borrowck<'tcx>(
415415

416416
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
417417

418-
tcx.emit_spanned_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
418+
tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
419419
}
420420

421421
let tainted_by_errors = mbcx.emit_errors();

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
563563
if codegen_fn_attrs.inline == InlineAttr::Always {
564564
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
565565
let hir_id = tcx.local_def_id_to_hir_id(did);
566-
tcx.struct_span_lint_hir(
566+
tcx.node_span_lint(
567567
lint::builtin::INLINE_NO_SANITIZE,
568568
hir_id,
569569
no_sanitize_span,

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub(super) fn lint<'tcx, 'mir, L>(
175175
{
176176
let (span, frames) = get_span_and_frames(tcx, machine);
177177

178-
tcx.emit_spanned_lint(
178+
tcx.emit_node_span_lint(
179179
lint,
180180
// We use the root frame for this so the crate that defines the const defines whether the
181181
// lint is emitted.

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
611611
.0
612612
.is_error();
613613
let span = ecx.cur_span();
614-
ecx.tcx.emit_spanned_lint(
614+
ecx.tcx.emit_node_span_lint(
615615
rustc_session::lint::builtin::LONG_RUNNING_CONST_EVAL,
616616
hir_id,
617617
span,

compiler/rustc_hir_analysis/src/astconv/generics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
656656
} else {
657657
let mut multispan = MultiSpan::from_span(span);
658658
multispan.push_span_label(span_late, note);
659-
tcx.struct_span_lint_hir(
659+
tcx.node_span_lint(
660660
LATE_BOUND_LIFETIME_ARGUMENTS,
661661
args.args[0].hir_id(),
662662
multispan,

compiler/rustc_hir_analysis/src/astconv/lint.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -240,24 +240,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
240240
diag.stash(self_ty.span, StashKey::TraitMissingMethod);
241241
} else {
242242
let msg = "trait objects without an explicit `dyn` are deprecated";
243-
tcx.struct_span_lint_hir(
244-
BARE_TRAIT_OBJECTS,
245-
self_ty.hir_id,
246-
self_ty.span,
247-
msg,
248-
|lint| {
249-
if self_ty.span.can_be_used_for_suggestions()
250-
&& !self.maybe_lint_impl_trait(self_ty, lint)
251-
{
252-
lint.multipart_suggestion_verbose(
253-
"use `dyn`",
254-
sugg,
255-
Applicability::MachineApplicable,
256-
);
257-
}
258-
self.maybe_lint_blanket_trait_impl(self_ty, lint);
259-
},
260-
);
243+
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| {
244+
if self_ty.span.can_be_used_for_suggestions()
245+
&& !self.maybe_lint_impl_trait(self_ty, lint)
246+
{
247+
lint.multipart_suggestion_verbose(
248+
"use `dyn`",
249+
sugg,
250+
Applicability::MachineApplicable,
251+
);
252+
}
253+
self.maybe_lint_blanket_trait_impl(self_ty, lint);
254+
});
261255
}
262256
}
263257
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13941394
let ty = self.projected_ty_from_poly_trait_ref(span, assoc_ty_did, assoc_segment, bound);
13951395

13961396
if let Some(variant_def_id) = variant_resolution {
1397-
tcx.struct_span_lint_hir(
1397+
tcx.node_span_lint(
13981398
AMBIGUOUS_ASSOCIATED_ITEMS,
13991399
hir_ref_id,
14001400
span,

compiler/rustc_hir_analysis/src/astconv/object_safety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
220220
let def_id = projection_bound.projection_def_id();
221221
def_ids.remove(&def_id);
222222
if tcx.generics_require_sized_self(def_id) {
223-
tcx.emit_spanned_lint(
223+
tcx.emit_node_span_lint(
224224
UNUSED_ASSOCIATED_TYPE_BOUNDS,
225225
hir_id,
226226
*span,

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
4646
.emit();
4747
}
4848
None => {
49-
tcx.struct_span_lint_hir(
49+
tcx.node_span_lint(
5050
UNSUPPORTED_CALLING_CONVENTIONS,
5151
hir_id,
5252
span,
@@ -183,7 +183,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
183183
}
184184
};
185185
if layout.abi.is_uninhabited() {
186-
tcx.struct_span_lint_hir(
186+
tcx.node_span_lint(
187187
UNINHABITED_STATIC,
188188
tcx.local_def_id_to_hir_id(def_id),
189189
span,
@@ -1079,7 +1079,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
10791079
// If there are any non-trivial fields, then there can be no non-exhaustive 1-zsts.
10801080
// Otherwise, it's only an issue if there's >1 non-exhaustive 1-zst.
10811081
if non_trivial_count > 0 || prev_non_exhaustive_1zst {
1082-
tcx.struct_span_lint_hir(
1082+
tcx.node_span_lint(
10831083
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
10841084
tcx.local_def_id_to_hir_id(adt.did().expect_local()),
10851085
span,

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
283283
});
284284

285285
let span = unmatched_bound.unwrap_or(span);
286-
tcx.emit_spanned_lint(
286+
tcx.emit_node_span_lint(
287287
REFINING_IMPL_TRAIT,
288288
tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()),
289289
span,

0 commit comments

Comments
 (0)