Skip to content

Commit c151782

Browse files
committed
reduce diversity in linting methods
1 parent b93addb commit c151782

File tree

4 files changed

+19
-41
lines changed

4 files changed

+19
-41
lines changed

src/librustc/traits/object_safety.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,17 @@ fn object_safety_violations_for_trait(
179179
{
180180
// Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise id.
181181
// It's also hard to get a use site span, so we use the method definition span.
182-
tcx.lint_node_note(
182+
tcx.struct_span_lint_hir(
183183
WHERE_CLAUSES_OBJECT_SAFETY,
184184
hir::CRATE_HIR_ID,
185185
*span,
186186
&format!(
187187
"the trait `{}` cannot be made into an object",
188188
tcx.def_path_str(trait_def_id)
189189
),
190-
&violation.error_msg(),
191-
);
190+
)
191+
.note(&violation.error_msg())
192+
.emit();
192193
false
193194
} else {
194195
true

src/librustc/ty/context.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,32 +2562,6 @@ impl<'tcx> TyCtxt<'tcx> {
25622562
self.struct_span_lint_hir(lint, hir_id, span.into(), msg).emit()
25632563
}
25642564

2565-
pub fn lint_hir_note(
2566-
self,
2567-
lint: &'static Lint,
2568-
hir_id: HirId,
2569-
span: impl Into<MultiSpan>,
2570-
msg: &str,
2571-
note: &str,
2572-
) {
2573-
let mut err = self.struct_span_lint_hir(lint, hir_id, span.into(), msg);
2574-
err.note(note);
2575-
err.emit()
2576-
}
2577-
2578-
pub fn lint_node_note(
2579-
self,
2580-
lint: &'static Lint,
2581-
id: hir::HirId,
2582-
span: impl Into<MultiSpan>,
2583-
msg: &str,
2584-
note: &str,
2585-
) {
2586-
let mut err = self.struct_span_lint_hir(lint, id, span.into(), msg);
2587-
err.note(note);
2588-
err.emit()
2589-
}
2590-
25912565
/// Walks upwards from `id` to find a node which might change lint levels with attributes.
25922566
/// It stops at `bound` and just returns it if reached.
25932567
pub fn maybe_lint_level_root_bounded(

src/librustc_mir/transform/check_unsafety.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,17 +648,17 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
648648
if let Some(impl_def_id) = builtin_derive_def_id(tcx, def_id) {
649649
tcx.unsafe_derive_on_repr_packed(impl_def_id);
650650
} else {
651-
tcx.lint_node_note(
651+
tcx.struct_span_lint_hir(
652652
SAFE_PACKED_BORROWS,
653653
lint_hir_id,
654654
source_info.span,
655655
&format!(
656-
"{} is unsafe and requires unsafe function or block \
657-
(error E0133)",
656+
"{} is unsafe and requires unsafe function or block (error E0133)",
658657
description
659658
),
660-
&details.as_str(),
661-
);
659+
)
660+
.note(&details.as_str())
661+
.emit();
662662
}
663663
}
664664
}

src/librustc_passes/liveness.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,13 +1513,16 @@ impl<'tcx> Liveness<'_, 'tcx> {
15131513
if ln == self.s.exit_ln { false } else { self.assigned_on_exit(ln, var).is_some() };
15141514

15151515
if is_assigned {
1516-
self.ir.tcx.lint_hir_note(
1517-
lint::builtin::UNUSED_VARIABLES,
1518-
hir_id,
1519-
spans,
1520-
&format!("variable `{}` is assigned to, but never used", name),
1521-
&format!("consider using `_{}` instead", name),
1522-
);
1516+
self.ir
1517+
.tcx
1518+
.struct_span_lint_hir(
1519+
lint::builtin::UNUSED_VARIABLES,
1520+
hir_id,
1521+
spans,
1522+
&format!("variable `{}` is assigned to, but never used", name),
1523+
)
1524+
.note(&format!("consider using `_{}` instead", name))
1525+
.emit();
15231526
} else {
15241527
let mut err = self.ir.tcx.struct_span_lint_hir(
15251528
lint::builtin::UNUSED_VARIABLES,

0 commit comments

Comments
 (0)