mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Use diagnostic items to check for Send, UnwindSafe and RefUnwindSafe traits
This commit is contained in:
parent
3e569dd2df
commit
06afafd492
@ -690,12 +690,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
// Blacklist traits for which it would be nonsensical to suggest borrowing.
|
// Blacklist traits for which it would be nonsensical to suggest borrowing.
|
||||||
// For instance, immutable references are always Copy, so suggesting to
|
// For instance, immutable references are always Copy, so suggesting to
|
||||||
// borrow would always succeed, but it's probably not what the user wanted.
|
// borrow would always succeed, but it's probably not what the user wanted.
|
||||||
let blacklist: Vec<_> =
|
let mut blacklist: Vec<_> =
|
||||||
[LangItem::Copy, LangItem::Clone, LangItem::Unpin, LangItem::Sized, LangItem::Send]
|
[LangItem::Copy, LangItem::Clone, LangItem::Unpin, LangItem::Sized]
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|lang_item| self.tcx.lang_items().require(*lang_item).ok())
|
.filter_map(|lang_item| self.tcx.lang_items().require(*lang_item).ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
blacklist.push(self.tcx.get_diagnostic_item(sym::send_trait).unwrap());
|
||||||
|
|
||||||
let span = obligation.cause.span;
|
let span = obligation.cause.span;
|
||||||
let param_env = obligation.param_env;
|
let param_env = obligation.param_env;
|
||||||
let trait_ref = trait_ref.skip_binder();
|
let trait_ref = trait_ref.skip_binder();
|
||||||
|
@ -663,7 +663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
if self.need_2229_migrations_for_trait(
|
if self.need_2229_migrations_for_trait(
|
||||||
min_captures,
|
min_captures,
|
||||||
var_hir_id,
|
var_hir_id,
|
||||||
tcx.lang_items().send_trait(),
|
tcx.get_diagnostic_item(sym::send_trait),
|
||||||
) {
|
) {
|
||||||
auto_trait_reasons.insert("`Send`");
|
auto_trait_reasons.insert("`Send`");
|
||||||
}
|
}
|
||||||
@ -679,7 +679,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
if self.need_2229_migrations_for_trait(
|
if self.need_2229_migrations_for_trait(
|
||||||
min_captures,
|
min_captures,
|
||||||
var_hir_id,
|
var_hir_id,
|
||||||
tcx.lang_items().unwind_safe_trait(),
|
tcx.get_diagnostic_item(sym::unwind_safe_trait),
|
||||||
) {
|
) {
|
||||||
auto_trait_reasons.insert("`UnwindSafe`");
|
auto_trait_reasons.insert("`UnwindSafe`");
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
if self.need_2229_migrations_for_trait(
|
if self.need_2229_migrations_for_trait(
|
||||||
min_captures,
|
min_captures,
|
||||||
var_hir_id,
|
var_hir_id,
|
||||||
tcx.lang_items().ref_unwind_safe_trait(),
|
tcx.get_diagnostic_item(sym::ref_unwind_safe_trait),
|
||||||
) {
|
) {
|
||||||
auto_trait_reasons.insert("`RefUnwindSafe`");
|
auto_trait_reasons.insert("`RefUnwindSafe`");
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ pub fn panic_any<M: 'static + Any + Send>(msg: M) -> ! {
|
|||||||
/// [`AssertUnwindSafe`] wrapper struct can be used to force this trait to be
|
/// [`AssertUnwindSafe`] wrapper struct can be used to force this trait to be
|
||||||
/// implemented for any closed over variables passed to `catch_unwind`.
|
/// implemented for any closed over variables passed to `catch_unwind`.
|
||||||
#[stable(feature = "catch_unwind", since = "1.9.0")]
|
#[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(
|
#[rustc_on_unimplemented(
|
||||||
message = "the type `{Self}` may not be safely transferred across an unwind boundary",
|
message = "the type `{Self}` may not be safely transferred across an unwind boundary",
|
||||||
label = "`{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
|
/// This is a "helper marker trait" used to provide impl blocks for the
|
||||||
/// [`UnwindSafe`] trait, for more information see that documentation.
|
/// [`UnwindSafe`] trait, for more information see that documentation.
|
||||||
#[stable(feature = "catch_unwind", since = "1.9.0")]
|
#[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(
|
#[rustc_on_unimplemented(
|
||||||
message = "the type `{Self}` may contain interior mutability and a reference may not be safely \
|
message = "the type `{Self}` may contain interior mutability and a reference may not be safely \
|
||||||
transferrable across a catch_unwind boundary",
|
transferrable across a catch_unwind boundary",
|
||||||
|
Loading…
Reference in New Issue
Block a user