Skip to content

Commit be76bdf

Browse files
committed
Remove ToPredicate impls that use Binder::dummy
1 parent 2c7bc5e commit be76bdf

File tree

27 files changed

+99
-85
lines changed

27 files changed

+99
-85
lines changed

compiler/rustc_borrowck/src/type_check/canonical.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
8989
category: ConstraintCategory,
9090
) {
9191
self.prove_predicates(
92-
Some(ty::PredicateKind::Trait(ty::TraitPredicate {
92+
Some(ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate {
9393
trait_ref,
9494
constness: ty::BoundConstness::NotConst,
95-
})),
95+
}))),
9696
locations,
9797
category,
9898
);

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
10781078
}
10791079

10801080
self.prove_predicate(
1081-
ty::PredicateKind::WellFormed(inferred_ty.into()).to_predicate(self.tcx()),
1081+
ty::Binder::dummy(ty::PredicateKind::WellFormed(inferred_ty.into()))
1082+
.to_predicate(self.tcx()),
10821083
Locations::All(span),
10831084
ConstraintCategory::TypeAnnotation,
10841085
);
@@ -1314,7 +1315,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13141315
obligations.obligations.push(traits::Obligation::new(
13151316
ObligationCause::dummy(),
13161317
param_env,
1317-
ty::PredicateKind::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx),
1318+
ty::Binder::dummy(ty::PredicateKind::WellFormed(revealed_ty.into()))
1319+
.to_predicate(infcx.tcx),
13181320
));
13191321
obligations.add(
13201322
infcx
@@ -1584,7 +1586,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15841586
self.check_call_dest(body, term, &sig, destination, term_location);
15851587

15861588
self.prove_predicates(
1587-
sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty.into())),
1589+
sig.inputs_and_output
1590+
.iter()
1591+
.map(|ty| ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()))),
15881592
term_location.to_locations(),
15891593
ConstraintCategory::Boring,
15901594
);

compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,10 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
669669
self.obligations.push(Obligation {
670670
cause: self.cause.clone(),
671671
param_env: self.param_env,
672-
predicate: ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(sup, sub))
673-
.to_predicate(self.infcx.tcx),
672+
predicate: ty::Binder::dummy(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
673+
sup, sub,
674+
)))
675+
.to_predicate(self.infcx.tcx),
674676
recursion_depth: 0,
675677
});
676678
}

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
360360
self.obligations.push(Obligation::new(
361361
self.trace.cause.clone(),
362362
self.param_env,
363-
ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
363+
ty::Binder::dummy(ty::PredicateKind::WellFormed(b_ty.into()))
364+
.to_predicate(self.infcx.tcx),
364365
));
365366
}
366367

@@ -463,7 +464,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
463464
self.obligations.push(Obligation::new(
464465
self.trace.cause.clone(),
465466
self.param_env,
466-
predicate.to_predicate(self.tcx()),
467+
ty::Binder::dummy(predicate).to_predicate(self.tcx()),
467468
));
468469
}
469470
}

compiler/rustc_infer/src/infer/sub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
9797
self.fields.obligations.push(Obligation::new(
9898
self.fields.trace.cause.clone(),
9999
self.fields.param_env,
100-
ty::PredicateKind::Subtype(ty::SubtypePredicate {
100+
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
101101
a_is_expected: self.a_is_expected,
102102
a,
103103
b,
104-
})
104+
}))
105105
.to_predicate(self.tcx()),
106106
));
107107

compiler/rustc_infer/src/traits/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
3434
cause,
3535
recursion_depth: 0,
3636
param_env,
37-
predicate: trait_ref.without_const().to_predicate(infcx.tcx),
37+
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(infcx.tcx),
3838
},
3939
);
4040
}

compiler/rustc_infer/src/traits/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ impl Elaborator<'tcx> {
231231
None
232232
}
233233
})
234+
.map(ty::Binder::dummy)
234235
.map(|predicate_kind| predicate_kind.to_predicate(tcx))
235236
.filter(|&predicate| visited.insert(predicate))
236237
.map(|predicate| {

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -792,23 +792,6 @@ impl ToPredicate<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
792792
}
793793
}
794794

795-
impl ToPredicate<'tcx> for PredicateKind<'tcx> {
796-
#[inline(always)]
797-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
798-
tcx.mk_predicate(Binder::dummy(self))
799-
}
800-
}
801-
802-
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
803-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
804-
PredicateKind::Trait(ty::TraitPredicate {
805-
trait_ref: self.value,
806-
constness: self.constness,
807-
})
808-
.to_predicate(tcx)
809-
}
810-
}
811-
812795
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
813796
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
814797
self.value

compiler/rustc_trait_selection/src/autoderef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
135135
let obligation = traits::Obligation::new(
136136
cause.clone(),
137137
self.param_env,
138-
trait_ref.without_const().to_predicate(tcx),
138+
ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
139139
);
140140
if !self.infcx.predicate_may_hold(&obligation) {
141141
debug!("overloaded_deref_ty: cannot match obligation");

compiler/rustc_trait_selection/src/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
120120
cause: traits::ObligationCause::dummy(),
121121
param_env,
122122
recursion_depth: 0,
123-
predicate: trait_ref.without_const().to_predicate(self.tcx),
123+
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(self.tcx),
124124
};
125125
self.evaluate_obligation(&obligation).unwrap_or(traits::EvaluationResult::EvaluatedToErr)
126126
}

0 commit comments

Comments
 (0)