diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index e4309dd28f4..ce57fb81104 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -179,7 +179,7 @@ fn object_safety_violations_for_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.lint_node_note( + tcx.struct_span_lint_hir( WHERE_CLAUSES_OBJECT_SAFETY, hir::CRATE_HIR_ID, *span, @@ -187,8 +187,9 @@ fn object_safety_violations_for_trait( "the trait `{}` cannot be made into an object", tcx.def_path_str(trait_def_id) ), - &violation.error_msg(), - ); + ) + .note(&violation.error_msg()) + .emit(); false } else { true diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index a97f33b31b7..eb65caf6fbe 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2562,32 +2562,6 @@ impl<'tcx> TyCtxt<'tcx> { self.struct_span_lint_hir(lint, hir_id, span.into(), msg).emit() } - pub fn lint_hir_note( - self, - lint: &'static Lint, - hir_id: HirId, - span: impl Into, - msg: &str, - note: &str, - ) { - let mut err = self.struct_span_lint_hir(lint, hir_id, span.into(), msg); - err.note(note); - err.emit() - } - - pub fn lint_node_note( - self, - lint: &'static Lint, - id: hir::HirId, - span: impl Into, - msg: &str, - note: &str, - ) { - let mut err = self.struct_span_lint_hir(lint, id, span.into(), msg); - err.note(note); - err.emit() - } - /// Walks upwards from `id` to find a node which might change lint levels with attributes. /// It stops at `bound` and just returns it if reached. pub fn maybe_lint_level_root_bounded( diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 02c54803842..3f342a6e6ca 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -648,17 +648,17 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) { if let Some(impl_def_id) = builtin_derive_def_id(tcx, def_id) { tcx.unsafe_derive_on_repr_packed(impl_def_id); } else { - tcx.lint_node_note( + tcx.struct_span_lint_hir( SAFE_PACKED_BORROWS, lint_hir_id, source_info.span, &format!( - "{} is unsafe and requires unsafe function or block \ - (error E0133)", + "{} is unsafe and requires unsafe function or block (error E0133)", description ), - &details.as_str(), - ); + ) + .note(&details.as_str()) + .emit(); } } } diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index 0426f3fbea2..7718139f6e9 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -1513,13 +1513,16 @@ impl<'tcx> Liveness<'_, 'tcx> { if ln == self.s.exit_ln { false } else { self.assigned_on_exit(ln, var).is_some() }; if is_assigned { - self.ir.tcx.lint_hir_note( - lint::builtin::UNUSED_VARIABLES, - hir_id, - spans, - &format!("variable `{}` is assigned to, but never used", name), - &format!("consider using `_{}` instead", name), - ); + self.ir + .tcx + .struct_span_lint_hir( + lint::builtin::UNUSED_VARIABLES, + hir_id, + spans, + &format!("variable `{}` is assigned to, but never used", name), + ) + .note(&format!("consider using `_{}` instead", name)) + .emit(); } else { let mut err = self.ir.tcx.struct_span_lint_hir( lint::builtin::UNUSED_VARIABLES,