diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 5c35b515f3d0..13c14d26b70f 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -690,12 +690,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { // Blacklist traits for which it would be nonsensical to suggest borrowing. // For instance, immutable references are always Copy, so suggesting to // borrow would always succeed, but it's probably not what the user wanted. - let blacklist: Vec<_> = - [LangItem::Copy, LangItem::Clone, LangItem::Unpin, LangItem::Sized, LangItem::Send] + let mut blacklist: Vec<_> = + [LangItem::Copy, LangItem::Clone, LangItem::Unpin, LangItem::Sized] .iter() .filter_map(|lang_item| self.tcx.lang_items().require(*lang_item).ok()) .collect(); + blacklist.push(self.tcx.get_diagnostic_item(sym::send_trait).unwrap()); + let span = obligation.cause.span; let param_env = obligation.param_env; let trait_ref = trait_ref.skip_binder(); diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 7b5b14ae6c83..197c4e3b319a 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -663,7 +663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if self.need_2229_migrations_for_trait( min_captures, var_hir_id, - tcx.lang_items().send_trait(), + tcx.get_diagnostic_item(sym::send_trait), ) { auto_trait_reasons.insert("`Send`"); } @@ -679,7 +679,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if self.need_2229_migrations_for_trait( min_captures, var_hir_id, - tcx.lang_items().unwind_safe_trait(), + tcx.get_diagnostic_item(sym::unwind_safe_trait), ) { auto_trait_reasons.insert("`UnwindSafe`"); } @@ -687,7 +687,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if self.need_2229_migrations_for_trait( min_captures, var_hir_id, - tcx.lang_items().ref_unwind_safe_trait(), + tcx.get_diagnostic_item(sym::ref_unwind_safe_trait), ) { auto_trait_reasons.insert("`RefUnwindSafe`"); } diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 7931c4c0a5fc..7bc987db8814 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -133,7 +133,7 @@ pub fn panic_any(msg: M) -> ! { /// [`AssertUnwindSafe`] wrapper struct can be used to force this trait to be /// implemented for any closed over variables passed to `catch_unwind`. #[stable(feature = "catch_unwind", since = "1.9.0")] -#[rustc_diagnostic_item = "unwind_safe_trait"] +#[cfg_attr(not(test), rustc_diagnostic_item = "unwind_safe_trait")] #[rustc_on_unimplemented( message = "the type `{Self}` may not be safely transferred across an unwind boundary", label = "`{Self}` may not be safely transferred across an unwind boundary" @@ -149,7 +149,7 @@ pub auto trait UnwindSafe {} /// This is a "helper marker trait" used to provide impl blocks for the /// [`UnwindSafe`] trait, for more information see that documentation. #[stable(feature = "catch_unwind", since = "1.9.0")] -#[rustc_diagnostic_item = "ref_unwind_safe_trait"] +#[cfg_attr(not(test), rustc_diagnostic_item = "ref_unwind_safe_trait")] #[rustc_on_unimplemented( message = "the type `{Self}` may contain interior mutability and a reference may not be safely \ transferrable across a catch_unwind boundary",