Use diagnostic items to check for Send, UnwindSafe and RefUnwindSafe traits

This commit is contained in:
Roxane Fruytier
2021-06-29 14:17:25 -04:00
committed by Roxane
parent 3e569dd2df
commit 06afafd492
3 changed files with 9 additions and 7 deletions

View File

@@ -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();