diff options
| author | Michael Goulet <michael@errs.io> | 2024-03-21 15:46:40 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-03-22 11:16:57 -0400 |
| commit | 127e42d33b21f05a7d1f2b1925fa28cf37e496c5 (patch) | |
| tree | d177f9fbfa2bd537b77f7dabe894e158f712e791 | |
| parent | 4b87c0b9c98e6399d62550e3293dfe625841731f (diff) | |
| download | rust-127e42d33b21f05a7d1f2b1925fa28cf37e496c5.tar.gz rust-127e42d33b21f05a7d1f2b1925fa28cf37e496c5.zip | |
Use != Positive rather than == Negative
Feels more complete, and for ImplPolarity has the side-effect of making sure we also handle reservation impls correctly
6 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 49b092f2276..6307b3ab6b2 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -710,7 +710,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // Don't register additional associated type bounds for negative bounds, // since we should have emitten an error for them earlier, and they will // not be well-formed! - if polarity == ty::PredicatePolarity::Negative { + if polarity != ty::PredicatePolarity::Positive { assert!( self.tcx().dcx().has_errors().is_some(), "negative trait bounds should not have bindings", diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index e6129e3a008..6a645d346ea 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -3367,7 +3367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "inherent impls can't be candidates, only trait impls can be", ) }) - .filter(|header| header.polarity == ty::ImplPolarity::Negative) + .filter(|header| header.polarity != ty::ImplPolarity::Positive) .any(|header| { let imp = header.trait_ref.instantiate_identity(); let imp_simp = diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs index 0876a54f16d..6d43011d33c 100644 --- a/compiler/rustc_infer/src/traits/util.rs +++ b/compiler/rustc_infer/src/traits/util.rs @@ -270,7 +270,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> { match bound_clause.skip_binder() { ty::ClauseKind::Trait(data) => { // Negative trait bounds do not imply any supertrait bounds - if data.polarity == ty::PredicatePolarity::Negative { + if data.polarity != ty::PredicatePolarity::Positive { return; } // Get predicates implied by the trait, or only super predicates if we only care about self predicates. diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 5a12e24a165..c909a0b49e2 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -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", 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 ca54207f618..729bbd56fc5 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -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; } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 4bc3ff92a67..ac5c54bfb79 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -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; |
