Skip to content

Commit d363f05

Browse files
committed
Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint.
1 parent 5222975 commit d363f05

File tree

33 files changed

+131
-143
lines changed

33 files changed

+131
-143
lines changed

compiler/rustc_borrowck/src/lib.rs

+1-1
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_const_eval/src/const_eval/error.rs

+1-1
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

+1-1
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/lint.rs

+12-18
Original file line numberDiff line numberDiff line change
@@ -228,24 +228,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
228228
diag.stash(self_ty.span, StashKey::TraitMissingMethod);
229229
} else {
230230
let msg = "trait objects without an explicit `dyn` are deprecated";
231-
tcx.node_span_lint(
232-
BARE_TRAIT_OBJECTS,
233-
self_ty.hir_id,
234-
self_ty.span,
235-
msg,
236-
|lint| {
237-
if self_ty.span.can_be_used_for_suggestions()
238-
&& !self.maybe_lint_impl_trait(self_ty, lint)
239-
{
240-
lint.multipart_suggestion_verbose(
241-
"use `dyn`",
242-
sugg,
243-
Applicability::MachineApplicable,
244-
);
245-
}
246-
self.maybe_lint_blanket_trait_impl(self_ty, lint);
247-
},
248-
);
231+
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| {
232+
if self_ty.span.can_be_used_for_suggestions()
233+
&& !self.maybe_lint_impl_trait(self_ty, lint)
234+
{
235+
lint.multipart_suggestion_verbose(
236+
"use `dyn`",
237+
sugg,
238+
Applicability::MachineApplicable,
239+
);
240+
}
241+
self.maybe_lint_blanket_trait_impl(self_ty, lint);
242+
});
249243
}
250244
}
251245
}

compiler/rustc_hir_analysis/src/astconv/object_safety.rs

+1-1
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/compare_impl_item/refine.rs

+1-1
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,

compiler/rustc_hir_analysis/src/check/errs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn handle_static_mut_ref(
8888
"shared ",
8989
)
9090
};
91-
tcx.emit_spanned_lint(
91+
tcx.emit_node_span_lint(
9292
STATIC_MUT_REF,
9393
hir_id,
9494
span,

compiler/rustc_hir_analysis/src/check_unused.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) {
4040
} else {
4141
"unused import".to_owned()
4242
};
43-
tcx.node_span_lint(
44-
lint::builtin::UNUSED_IMPORTS,
45-
item.hir_id(),
46-
path.span,
47-
msg,
48-
|_| {},
49-
);
43+
tcx.node_span_lint(lint::builtin::UNUSED_IMPORTS, item.hir_id(), path.span, msg, |_| {});
5044
}
5145
}

compiler/rustc_hir_typeck/src/cast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
587587
};
588588
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
589589
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
590-
fcx.tcx.emit_spanned_lint(
590+
fcx.tcx.emit_node_span_lint(
591591
lint,
592592
self.expr.hir_id,
593593
self.span,
@@ -900,7 +900,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
900900
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
901901
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
902902

903-
fcx.tcx.emit_spanned_lint(
903+
fcx.tcx.emit_node_span_lint(
904904
lint::builtin::CENUM_IMPL_DROP_CAST,
905905
self.expr.hir_id,
906906
self.span,
@@ -934,7 +934,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
934934
};
935935

936936
let lint = errors::LossyProvenancePtr2Int { expr_ty, cast_ty, sugg };
937-
fcx.tcx.emit_spanned_lint(
937+
fcx.tcx.emit_node_span_lint(
938938
lint::builtin::LOSSY_PROVENANCE_CASTS,
939939
self.expr.hir_id,
940940
self.span,
@@ -950,7 +950,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
950950
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
951951
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
952952
let lint = errors::LossyProvenanceInt2Ptr { expr_ty, cast_ty, sugg };
953-
fcx.tcx.emit_spanned_lint(
953+
fcx.tcx.emit_node_span_lint(
954954
lint::builtin::FUZZY_PROVENANCE_CASTS,
955955
self.expr.hir_id,
956956
self.span,

compiler/rustc_lint/src/async_fn_in_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait {
116116
def.owner_id.def_id,
117117
" + Send",
118118
);
119-
cx.tcx.emit_spanned_lint(
119+
cx.tcx.emit_node_span_lint(
120120
ASYNC_FN_IN_TRAIT,
121121
item.hir_id(),
122122
async_span,

compiler/rustc_lint/src/expect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
2929
{
3030
let rationale = expectation.reason.map(|rationale| ExpectationNote { rationale });
3131
let note = expectation.is_unfulfilled_lint_expectations.then_some(());
32-
tcx.emit_spanned_lint(
32+
tcx.emit_node_span_lint(
3333
UNFULFILLED_LINT_EXPECTATIONS,
3434
*hir_id,
3535
expectation.emission_span,

compiler/rustc_lint/src/foreign_modules.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl ClashingExternDeclarations {
161161
sub,
162162
}
163163
};
164-
tcx.emit_spanned_lint(
164+
tcx.emit_node_span_lint(
165165
CLASHING_EXTERN_DECLARATIONS,
166166
this_fi.hir_id(),
167167
mismatch_label,

compiler/rustc_middle/src/lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub fn explain_lint_level_source(
247247
///
248248
/// If you are looking to implement a lint, look for higher level functions,
249249
/// for example:
250-
/// - [`TyCtxt::emit_spanned_lint`]
250+
/// - [`TyCtxt::emit_node_span_lint`]
251251
/// - [`TyCtxt::node_span_lint`]
252252
/// - [`TyCtxt::emit_node_lint`]
253253
/// - [`TyCtxt::node_lint`]

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,7 @@ impl<'tcx> TyCtxt<'tcx> {
20562056
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
20572057
/// typically generated by `#[derive(LintDiagnostic)]`).
20582058
#[track_caller]
2059-
pub fn emit_spanned_lint(
2059+
pub fn emit_node_span_lint(
20602060
self,
20612061
lint: &'static Lint,
20622062
hir_id: HirId,

compiler/rustc_mir_build/src/check_unsafety.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl UnsafeOpKind {
599599
// FIXME: ideally we would want to trim the def paths, but this is not
600600
// feasible with the current lint emission API (see issue #106126).
601601
match self {
602-
CallToUnsafeFunction(Some(did)) => tcx.emit_spanned_lint(
602+
CallToUnsafeFunction(Some(did)) => tcx.emit_node_span_lint(
603603
UNSAFE_OP_IN_UNSAFE_FN,
604604
hir_id,
605605
span,
@@ -609,7 +609,7 @@ impl UnsafeOpKind {
609609
unsafe_not_inherited_note,
610610
},
611611
),
612-
CallToUnsafeFunction(None) => tcx.emit_spanned_lint(
612+
CallToUnsafeFunction(None) => tcx.emit_node_span_lint(
613613
UNSAFE_OP_IN_UNSAFE_FN,
614614
hir_id,
615615
span,
@@ -618,7 +618,7 @@ impl UnsafeOpKind {
618618
unsafe_not_inherited_note,
619619
},
620620
),
621-
UseOfInlineAssembly => tcx.emit_spanned_lint(
621+
UseOfInlineAssembly => tcx.emit_node_span_lint(
622622
UNSAFE_OP_IN_UNSAFE_FN,
623623
hir_id,
624624
span,
@@ -627,7 +627,7 @@ impl UnsafeOpKind {
627627
unsafe_not_inherited_note,
628628
},
629629
),
630-
InitializingTypeWith => tcx.emit_spanned_lint(
630+
InitializingTypeWith => tcx.emit_node_span_lint(
631631
UNSAFE_OP_IN_UNSAFE_FN,
632632
hir_id,
633633
span,
@@ -636,7 +636,7 @@ impl UnsafeOpKind {
636636
unsafe_not_inherited_note,
637637
},
638638
),
639-
UseOfMutableStatic => tcx.emit_spanned_lint(
639+
UseOfMutableStatic => tcx.emit_node_span_lint(
640640
UNSAFE_OP_IN_UNSAFE_FN,
641641
hir_id,
642642
span,
@@ -645,7 +645,7 @@ impl UnsafeOpKind {
645645
unsafe_not_inherited_note,
646646
},
647647
),
648-
UseOfExternStatic => tcx.emit_spanned_lint(
648+
UseOfExternStatic => tcx.emit_node_span_lint(
649649
UNSAFE_OP_IN_UNSAFE_FN,
650650
hir_id,
651651
span,
@@ -654,7 +654,7 @@ impl UnsafeOpKind {
654654
unsafe_not_inherited_note,
655655
},
656656
),
657-
DerefOfRawPointer => tcx.emit_spanned_lint(
657+
DerefOfRawPointer => tcx.emit_node_span_lint(
658658
UNSAFE_OP_IN_UNSAFE_FN,
659659
hir_id,
660660
span,
@@ -663,7 +663,7 @@ impl UnsafeOpKind {
663663
unsafe_not_inherited_note,
664664
},
665665
),
666-
AccessToUnionField => tcx.emit_spanned_lint(
666+
AccessToUnionField => tcx.emit_node_span_lint(
667667
UNSAFE_OP_IN_UNSAFE_FN,
668668
hir_id,
669669
span,
@@ -672,7 +672,7 @@ impl UnsafeOpKind {
672672
unsafe_not_inherited_note,
673673
},
674674
),
675-
MutationOfLayoutConstrainedField => tcx.emit_spanned_lint(
675+
MutationOfLayoutConstrainedField => tcx.emit_node_span_lint(
676676
UNSAFE_OP_IN_UNSAFE_FN,
677677
hir_id,
678678
span,
@@ -681,7 +681,7 @@ impl UnsafeOpKind {
681681
unsafe_not_inherited_note,
682682
},
683683
),
684-
BorrowOfLayoutConstrainedField => tcx.emit_spanned_lint(
684+
BorrowOfLayoutConstrainedField => tcx.emit_node_span_lint(
685685
UNSAFE_OP_IN_UNSAFE_FN,
686686
hir_id,
687687
span,
@@ -690,7 +690,7 @@ impl UnsafeOpKind {
690690
unsafe_not_inherited_note,
691691
},
692692
),
693-
CallToFunctionWith { function, missing, build_enabled } => tcx.emit_spanned_lint(
693+
CallToFunctionWith { function, missing, build_enabled } => tcx.emit_node_span_lint(
694694
UNSAFE_OP_IN_UNSAFE_FN,
695695
hir_id,
696696
span,
@@ -941,7 +941,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
941941
warnings.sort_by_key(|w| w.block_span);
942942
for UnusedUnsafeWarning { hir_id, block_span, enclosing_unsafe } in warnings {
943943
let block_span = tcx.sess.source_map().guess_head_span(block_span);
944-
tcx.emit_spanned_lint(
944+
tcx.emit_node_span_lint(
945945
UNUSED_UNSAFE,
946946
hir_id,
947947
block_span,

compiler/rustc_mir_build/src/lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn check_recursion<'tcx>(
5353

5454
let sp = tcx.def_span(def_id);
5555
let hir_id = tcx.local_def_id_to_hir_id(def_id);
56-
tcx.emit_spanned_lint(
56+
tcx.emit_node_span_lint(
5757
UNCONDITIONAL_RECURSION,
5858
hir_id,
5959
sp,

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
515515
let span_end = prefix.last().unwrap().unwrap().0;
516516
let span = span_start.to(span_end);
517517
let count = prefix.len();
518-
self.tcx.emit_spanned_lint(
518+
self.tcx.emit_node_span_lint(
519519
IRREFUTABLE_LET_PATTERNS,
520520
self.lint_level,
521521
span,
@@ -534,7 +534,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
534534
let span_end = suffix.last().unwrap().unwrap().0;
535535
let span = span_start.to(span_end);
536536
let count = suffix.len();
537-
self.tcx.emit_spanned_lint(
537+
self.tcx.emit_node_span_lint(
538538
IRREFUTABLE_LET_PATTERNS,
539539
self.lint_level,
540540
span,
@@ -791,7 +791,7 @@ fn check_for_bindings_named_same_as_variants(
791791
{
792792
let variant_count = edef.variants().len();
793793
let ty_path = with_no_trimmed_paths!(cx.tcx.def_path_str(edef.did()));
794-
cx.tcx.emit_spanned_lint(
794+
cx.tcx.emit_node_span_lint(
795795
BINDINGS_WITH_VARIANT_NAME,
796796
cx.lint_level,
797797
pat.span,
@@ -820,7 +820,7 @@ fn report_irrefutable_let_patterns(
820820
) {
821821
macro_rules! emit_diag {
822822
($lint:tt) => {{
823-
tcx.emit_spanned_lint(IRREFUTABLE_LET_PATTERNS, id, span, $lint { count });
823+
tcx.emit_node_span_lint(IRREFUTABLE_LET_PATTERNS, id, span, $lint { count });
824824
}};
825825
}
826826

@@ -839,7 +839,7 @@ fn report_arm_reachability<'p, 'tcx>(
839839
report: &UsefulnessReport<'p, 'tcx>,
840840
) {
841841
let report_unreachable_pattern = |span, hir_id, catchall: Option<Span>| {
842-
cx.tcx.emit_spanned_lint(
842+
cx.tcx.emit_node_span_lint(
843843
UNREACHABLE_PATTERNS,
844844
hir_id,
845845
span,

0 commit comments

Comments
 (0)