Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4b87c0b

Browse files
Split out ImplPolarity and PredicatePolarity
1 parent 1447f9d commit 4b87c0b

File tree

30 files changed

+169
-95
lines changed

30 files changed

+169
-95
lines changed

compiler/rustc_borrowck/src/type_check/canonical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
8282
) {
8383
self.prove_predicate(
8484
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Trait(
85-
ty::TraitPredicate { trait_ref, polarity: ty::ImplPolarity::Positive },
85+
ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive },
8686
))),
8787
locations,
8888
category,

compiler/rustc_hir_analysis/src/bounds.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'tcx> Bounds<'tcx> {
4242
tcx: TyCtxt<'tcx>,
4343
trait_ref: ty::PolyTraitRef<'tcx>,
4444
span: Span,
45-
polarity: ty::ImplPolarity,
45+
polarity: ty::PredicatePolarity,
4646
) {
4747
self.push_trait_bound_inner(tcx, trait_ref, span, polarity);
4848
}
@@ -52,7 +52,7 @@ impl<'tcx> Bounds<'tcx> {
5252
tcx: TyCtxt<'tcx>,
5353
trait_ref: ty::PolyTraitRef<'tcx>,
5454
span: Span,
55-
polarity: ty::ImplPolarity,
55+
polarity: ty::PredicatePolarity,
5656
) {
5757
self.clauses.push((
5858
trait_ref

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ fn check_impl<'tcx>(
13221322
trait_ref,
13231323
);
13241324
let trait_pred =
1325-
ty::TraitPredicate { trait_ref, polarity: ty::ImplPolarity::Positive };
1325+
ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive };
13261326
let mut obligations = traits::wf::trait_obligations(
13271327
wfcx.infcx,
13281328
wfcx.param_env,

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ fn infringing_fields_error(
551551
}
552552
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
553553
trait_ref,
554-
polarity: ty::ImplPolarity::Positive,
554+
polarity: ty::PredicatePolarity::Positive,
555555
..
556556
})) = error_predicate.kind().skip_binder()
557557
{

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ pub(super) fn implied_predicates_with_filter(
624624
for &(pred, span) in implied_bounds {
625625
debug!("superbound: {:?}", pred);
626626
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
627-
&& bound.polarity == ty::ImplPolarity::Positive
627+
&& bound.polarity == ty::PredicatePolarity::Positive
628628
{
629629
tcx.at(span).super_predicates_of(bound.def_id());
630630
}
@@ -634,7 +634,7 @@ pub(super) fn implied_predicates_with_filter(
634634
for &(pred, span) in implied_bounds {
635635
debug!("superbound: {:?}", pred);
636636
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
637-
&& bound.polarity == ty::ImplPolarity::Positive
637+
&& bound.polarity == ty::PredicatePolarity::Positive
638638
{
639639
tcx.at(span).implied_predicates_of(bound.def_id());
640640
}

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,16 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
140140
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
141141
let (constness, polarity) = match modifier {
142142
hir::TraitBoundModifier::Const => {
143-
(ty::BoundConstness::Const, ty::ImplPolarity::Positive)
143+
(ty::BoundConstness::Const, ty::PredicatePolarity::Positive)
144144
}
145145
hir::TraitBoundModifier::MaybeConst => {
146-
(ty::BoundConstness::ConstIfConst, ty::ImplPolarity::Positive)
146+
(ty::BoundConstness::ConstIfConst, ty::PredicatePolarity::Positive)
147147
}
148148
hir::TraitBoundModifier::None => {
149-
(ty::BoundConstness::NotConst, ty::ImplPolarity::Positive)
149+
(ty::BoundConstness::NotConst, ty::PredicatePolarity::Positive)
150150
}
151151
hir::TraitBoundModifier::Negative => {
152-
(ty::BoundConstness::NotConst, ty::ImplPolarity::Negative)
152+
(ty::BoundConstness::NotConst, ty::PredicatePolarity::Negative)
153153
}
154154
hir::TraitBoundModifier::Maybe => continue,
155155
};

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
673673
trait_ref: &hir::TraitRef<'tcx>,
674674
span: Span,
675675
constness: ty::BoundConstness,
676-
polarity: ty::ImplPolarity,
676+
polarity: ty::PredicatePolarity,
677677
self_ty: Ty<'tcx>,
678678
bounds: &mut Bounds<'tcx>,
679679
only_self_bounds: OnlySelfBounds,
@@ -710,7 +710,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
710710
// Don't register additional associated type bounds for negative bounds,
711711
// since we should have emitten an error for them earlier, and they will
712712
// not be well-formed!
713-
if polarity == ty::ImplPolarity::Negative {
713+
if polarity == ty::PredicatePolarity::Negative {
714714
assert!(
715715
self.tcx().dcx().has_errors().is_some(),
716716
"negative trait bounds should not have bindings",

compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
4343
&trait_bound.trait_ref,
4444
trait_bound.span,
4545
ty::BoundConstness::NotConst,
46-
ty::ImplPolarity::Positive,
46+
ty::PredicatePolarity::Positive,
4747
dummy_self,
4848
&mut bounds,
4949
// True so we don't populate `bounds` with associated type bounds, even
@@ -60,7 +60,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
6060
let bound_pred = pred.kind();
6161
match bound_pred.skip_binder() {
6262
ty::ClauseKind::Trait(trait_pred) => {
63-
assert_eq!(trait_pred.polarity, ty::ImplPolarity::Positive);
63+
assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
6464
trait_bounds.push((bound_pred.rebind(trait_pred.trait_ref), span));
6565
}
6666
ty::ClauseKind::Projection(proj) => {

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3100,7 +3100,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31003100
cause.clone().derived_cause(
31013101
ty::Binder::dummy(ty::TraitPredicate {
31023102
trait_ref: impl_trait_ref,
3103-
polarity: ty::ImplPolarity::Positive,
3103+
polarity: ty::PredicatePolarity::Positive,
31043104
}),
31053105
|derived| {
31063106
traits::ImplDerivedObligation(Box::new(

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
875875
match pred.kind().skip_binder() {
876876
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
877877
Some(pred.def_id()) == self.tcx.lang_items().sized_trait()
878-
&& pred.polarity == ty::ImplPolarity::Positive
878+
&& pred.polarity == ty::PredicatePolarity::Positive
879879
}
880880
_ => false,
881881
}

0 commit comments

Comments
 (0)