1
Fork 0

Ignore trait implementations with negative polarity when suggesting trait implementations in diagnostics

This commit is contained in:
ThePuzzlemaker 2020-12-01 12:57:19 -06:00
parent 4cbda829c0
commit 3c4bc8c8ad
No known key found for this signature in database
GPG key ID: 968CD9D71C9FBB6C

View file

@ -1310,10 +1310,20 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
return None;
}
}
if self.tcx.impl_polarity(def_id) == ty::ImplPolarity::Negative {
return None;
}
Some(imp)
})
.collect(),
None => all_impls.map(|def_id| self.tcx.impl_trait_ref(def_id).unwrap()).collect(),
None => all_impls
.filter_map(|def_id| {
if self.tcx.impl_polarity(def_id) == ty::ImplPolarity::Negative {
return None;
}
self.tcx.impl_trait_ref(def_id)
})
.collect(),
}
}