Use != Positive rather than == Negative

Feels more complete, and for ImplPolarity has the side-effect of making
sure we also handle reservation impls correctly
This commit is contained in:
Michael Goulet 2024-03-21 15:46:40 -04:00
parent 4b87c0b9c9
commit 127e42d33b
6 changed files with 6 additions and 6 deletions

View file

@ -295,7 +295,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
}) = impl_source
{
// Blame 'tidy' for the weird bracket placement.
if infcx.tcx.impl_polarity(*impl_def_id) == ty::ImplPolarity::Negative {
if infcx.tcx.impl_polarity(*impl_def_id) != ty::ImplPolarity::Positive {
debug!(
"evaluate_nested_obligations: found explicit negative impl\
{:?}, bailing out",

View file

@ -245,7 +245,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
associated_ty: Option<(&'static str, Ty<'tcx>)>,
mut body_id: LocalDefId,
) {
if trait_pred.skip_binder().polarity == ty::PredicatePolarity::Negative {
if trait_pred.skip_binder().polarity != ty::PredicatePolarity::Positive {
return;
}

View file

@ -1907,7 +1907,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
.all_impls(trait_pred.def_id())
.filter_map(|def_id| {
let imp = self.tcx.impl_trait_header(def_id).unwrap();
if imp.polarity == ty::ImplPolarity::Negative
if imp.polarity != ty::ImplPolarity::Positive
|| !self.tcx.is_user_visible_dep(def_id.krate)
{
return None;