Skip to content

Commit a090b45

Browse files
committed
avoid more ty::Binder:dummy
1 parent c115ec1 commit a090b45

File tree

8 files changed

+29
-36
lines changed

8 files changed

+29
-36
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,12 +1338,25 @@ impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
13381338
}
13391339
}
13401340

1341+
impl<'tcx> ToPredicate<'tcx> for ProjectionPredicate<'tcx> {
1342+
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
1343+
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(self))).to_predicate(tcx)
1344+
}
1345+
}
1346+
13411347
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
13421348
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13431349
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).to_predicate(tcx)
13441350
}
13451351
}
13461352

1353+
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for ProjectionPredicate<'tcx> {
1354+
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
1355+
let p: Predicate<'tcx> = self.to_predicate(tcx);
1356+
p.expect_clause()
1357+
}
1358+
}
1359+
13471360
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> {
13481361
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
13491362
let p: Predicate<'tcx> = self.to_predicate(tcx);

compiler/rustc_trait_selection/src/solve/alias_relate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
162162
self.add_goal(Goal::new(
163163
self.tcx(),
164164
param_env,
165-
ty::Binder::dummy(ty::ProjectionPredicate { projection_ty: alias, term: other }),
165+
ty::ProjectionPredicate { projection_ty: alias, term: other },
166166
));
167167

168168
Ok(())

compiler/rustc_trait_selection/src/solve/assembly/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
413413
let normalized_ty = ecx.next_ty_infer();
414414
let normalizes_to_goal = goal.with(
415415
tcx,
416-
ty::Binder::dummy(ty::ProjectionPredicate {
417-
projection_ty,
418-
term: normalized_ty.into(),
419-
}),
416+
ty::ProjectionPredicate { projection_ty, term: normalized_ty.into() },
420417
);
421418
ecx.add_goal(normalizes_to_goal);
422419
let _ = ecx.try_evaluate_added_goals().inspect_err(|_| {

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
487487
let unconstrained_rhs = this.next_term_infer_of_kind(goal.predicate.term);
488488
let unconstrained_goal = goal.with(
489489
this.tcx(),
490-
ty::Binder::dummy(ty::ProjectionPredicate {
490+
ty::ProjectionPredicate {
491491
projection_ty: goal.predicate.projection_ty,
492492
term: unconstrained_rhs,
493-
}),
493+
},
494494
);
495495

496496
let (_, certainty, instantiate_goals) =

compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn rematch_unsize<'tcx>(
269269
infcx.tcx,
270270
ObligationCause::dummy(),
271271
goal.param_env,
272-
ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region)),
272+
ty::OutlivesPredicate(a_ty, region),
273273
));
274274

275275
Ok(Some(ImplSource::Builtin(source, nested)))

compiler/rustc_trait_selection/src/solve/normalize.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
7575
tcx,
7676
self.at.cause.clone(),
7777
self.at.param_env,
78-
ty::Binder::dummy(ty::ProjectionPredicate {
79-
projection_ty: alias,
80-
term: new_infer_ty.into(),
81-
}),
78+
ty::ProjectionPredicate { projection_ty: alias, term: new_infer_ty.into() },
8279
);
8380

8481
// Do not emit an error if normalization is known to fail but instead
@@ -131,10 +128,10 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
131128
tcx,
132129
self.at.cause.clone(),
133130
self.at.param_env,
134-
ty::Binder::dummy(ty::ProjectionPredicate {
131+
ty::ProjectionPredicate {
135132
projection_ty: tcx.mk_alias_ty(uv.def, uv.args),
136133
term: new_infer_ct.into(),
137-
}),
134+
},
138135
);
139136

140137
let result = if infcx.predicate_may_hold(&obligation) {

compiler/rustc_trait_selection/src/solve/project_goals.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
393393
None => tcx.types.unit,
394394
Some(field_def) => {
395395
let self_ty = field_def.ty(tcx, args);
396-
ecx.add_goal(goal.with(
397-
tcx,
398-
ty::Binder::dummy(goal.predicate.with_self_ty(tcx, self_ty)),
399-
));
396+
ecx.add_goal(goal.with(tcx, goal.predicate.with_self_ty(tcx, self_ty)));
400397
return ecx
401398
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
402399
}
@@ -406,10 +403,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
406403
ty::Tuple(elements) => match elements.last() {
407404
None => tcx.types.unit,
408405
Some(&self_ty) => {
409-
ecx.add_goal(goal.with(
410-
tcx,
411-
ty::Binder::dummy(goal.predicate.with_self_ty(tcx, self_ty)),
412-
));
406+
ecx.add_goal(goal.with(tcx, goal.predicate.with_self_ty(tcx, self_ty)));
413407
return ecx
414408
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
415409
}
@@ -450,10 +444,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
450444
Self::consider_implied_clause(
451445
ecx,
452446
goal,
453-
ty::Binder::dummy(ty::ProjectionPredicate {
447+
ty::ProjectionPredicate {
454448
projection_ty: ecx.tcx().mk_alias_ty(goal.predicate.def_id(), [self_ty]),
455449
term,
456-
})
450+
}
457451
.to_predicate(tcx),
458452
// Technically, we need to check that the future type is Sized,
459453
// but that's already proven by the generator being WF.
@@ -490,12 +484,12 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
490484
Self::consider_implied_clause(
491485
ecx,
492486
goal,
493-
ty::Binder::dummy(ty::ProjectionPredicate {
487+
ty::ProjectionPredicate {
494488
projection_ty: ecx
495489
.tcx()
496490
.mk_alias_ty(goal.predicate.def_id(), [self_ty, generator.resume_ty()]),
497491
term,
498-
})
492+
}
499493
.to_predicate(tcx),
500494
// Technically, we need to check that the future type is Sized,
501495
// but that's already proven by the generator being WF.

compiler/rustc_trait_selection/src/solve/trait_goals.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
857857
ecx.add_goals(
858858
constituent_tys(ecx, goal.predicate.self_ty())?
859859
.into_iter()
860-
.map(|ty| {
861-
goal.with(
862-
ecx.tcx(),
863-
ty::Binder::dummy(goal.predicate.with_self_ty(ecx.tcx(), ty)),
864-
)
865-
})
860+
.map(|ty| goal.with(ecx.tcx(), goal.predicate.with_self_ty(ecx.tcx(), ty)))
866861
.collect::<Vec<_>>(),
867862
);
868863
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
@@ -905,10 +900,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
905900
let normalizes_to_goal = Goal::new(
906901
ecx.tcx(),
907902
param_env,
908-
ty::Binder::dummy(ty::ProjectionPredicate {
909-
projection_ty,
910-
term: normalized_ty.into(),
911-
}),
903+
ty::ProjectionPredicate { projection_ty, term: normalized_ty.into() },
912904
);
913905
ecx.add_goal(normalizes_to_goal);
914906
if let Err(err) = ecx.try_evaluate_added_goals() {

0 commit comments

Comments
 (0)