mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
avoid more ty::Binder:dummy
This commit is contained in:
parent
c115ec11d2
commit
a090b4548d
@ -1338,12 +1338,25 @@ impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> ToPredicate<'tcx> for ProjectionPredicate<'tcx> {
|
||||||
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
|
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(self))).to_predicate(tcx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
|
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).to_predicate(tcx)
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for ProjectionPredicate<'tcx> {
|
||||||
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
||||||
|
let p: Predicate<'tcx> = self.to_predicate(tcx);
|
||||||
|
p.expect_clause()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> {
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
||||||
let p: Predicate<'tcx> = self.to_predicate(tcx);
|
let p: Predicate<'tcx> = self.to_predicate(tcx);
|
||||||
|
@ -162,7 +162,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
self.add_goal(Goal::new(
|
self.add_goal(Goal::new(
|
||||||
self.tcx(),
|
self.tcx(),
|
||||||
param_env,
|
param_env,
|
||||||
ty::Binder::dummy(ty::ProjectionPredicate { projection_ty: alias, term: other }),
|
ty::ProjectionPredicate { projection_ty: alias, term: other },
|
||||||
));
|
));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -413,10 +413,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
let normalized_ty = ecx.next_ty_infer();
|
let normalized_ty = ecx.next_ty_infer();
|
||||||
let normalizes_to_goal = goal.with(
|
let normalizes_to_goal = goal.with(
|
||||||
tcx,
|
tcx,
|
||||||
ty::Binder::dummy(ty::ProjectionPredicate {
|
ty::ProjectionPredicate { projection_ty, term: normalized_ty.into() },
|
||||||
projection_ty,
|
|
||||||
term: normalized_ty.into(),
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
ecx.add_goal(normalizes_to_goal);
|
ecx.add_goal(normalizes_to_goal);
|
||||||
let _ = ecx.try_evaluate_added_goals().inspect_err(|_| {
|
let _ = ecx.try_evaluate_added_goals().inspect_err(|_| {
|
||||||
|
@ -487,10 +487,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
|||||||
let unconstrained_rhs = this.next_term_infer_of_kind(goal.predicate.term);
|
let unconstrained_rhs = this.next_term_infer_of_kind(goal.predicate.term);
|
||||||
let unconstrained_goal = goal.with(
|
let unconstrained_goal = goal.with(
|
||||||
this.tcx(),
|
this.tcx(),
|
||||||
ty::Binder::dummy(ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: goal.predicate.projection_ty,
|
projection_ty: goal.predicate.projection_ty,
|
||||||
term: unconstrained_rhs,
|
term: unconstrained_rhs,
|
||||||
}),
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let (_, certainty, instantiate_goals) =
|
let (_, certainty, instantiate_goals) =
|
||||||
|
@ -269,7 +269,7 @@ fn rematch_unsize<'tcx>(
|
|||||||
infcx.tcx,
|
infcx.tcx,
|
||||||
ObligationCause::dummy(),
|
ObligationCause::dummy(),
|
||||||
goal.param_env,
|
goal.param_env,
|
||||||
ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region)),
|
ty::OutlivesPredicate(a_ty, region),
|
||||||
));
|
));
|
||||||
|
|
||||||
Ok(Some(ImplSource::Builtin(source, nested)))
|
Ok(Some(ImplSource::Builtin(source, nested)))
|
||||||
|
@ -75,10 +75,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
|
|||||||
tcx,
|
tcx,
|
||||||
self.at.cause.clone(),
|
self.at.cause.clone(),
|
||||||
self.at.param_env,
|
self.at.param_env,
|
||||||
ty::Binder::dummy(ty::ProjectionPredicate {
|
ty::ProjectionPredicate { projection_ty: alias, term: new_infer_ty.into() },
|
||||||
projection_ty: alias,
|
|
||||||
term: new_infer_ty.into(),
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Do not emit an error if normalization is known to fail but instead
|
// Do not emit an error if normalization is known to fail but instead
|
||||||
@ -131,10 +128,10 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
|
|||||||
tcx,
|
tcx,
|
||||||
self.at.cause.clone(),
|
self.at.cause.clone(),
|
||||||
self.at.param_env,
|
self.at.param_env,
|
||||||
ty::Binder::dummy(ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: tcx.mk_alias_ty(uv.def, uv.args),
|
projection_ty: tcx.mk_alias_ty(uv.def, uv.args),
|
||||||
term: new_infer_ct.into(),
|
term: new_infer_ct.into(),
|
||||||
}),
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let result = if infcx.predicate_may_hold(&obligation) {
|
let result = if infcx.predicate_may_hold(&obligation) {
|
||||||
|
@ -393,10 +393,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||||||
None => tcx.types.unit,
|
None => tcx.types.unit,
|
||||||
Some(field_def) => {
|
Some(field_def) => {
|
||||||
let self_ty = field_def.ty(tcx, args);
|
let self_ty = field_def.ty(tcx, args);
|
||||||
ecx.add_goal(goal.with(
|
ecx.add_goal(goal.with(tcx, goal.predicate.with_self_ty(tcx, self_ty)));
|
||||||
tcx,
|
|
||||||
ty::Binder::dummy(goal.predicate.with_self_ty(tcx, self_ty)),
|
|
||||||
));
|
|
||||||
return ecx
|
return ecx
|
||||||
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
|
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
|
||||||
}
|
}
|
||||||
@ -406,10 +403,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||||||
ty::Tuple(elements) => match elements.last() {
|
ty::Tuple(elements) => match elements.last() {
|
||||||
None => tcx.types.unit,
|
None => tcx.types.unit,
|
||||||
Some(&self_ty) => {
|
Some(&self_ty) => {
|
||||||
ecx.add_goal(goal.with(
|
ecx.add_goal(goal.with(tcx, goal.predicate.with_self_ty(tcx, self_ty)));
|
||||||
tcx,
|
|
||||||
ty::Binder::dummy(goal.predicate.with_self_ty(tcx, self_ty)),
|
|
||||||
));
|
|
||||||
return ecx
|
return ecx
|
||||||
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
|
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
|
||||||
}
|
}
|
||||||
@ -450,10 +444,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||||||
Self::consider_implied_clause(
|
Self::consider_implied_clause(
|
||||||
ecx,
|
ecx,
|
||||||
goal,
|
goal,
|
||||||
ty::Binder::dummy(ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: ecx.tcx().mk_alias_ty(goal.predicate.def_id(), [self_ty]),
|
projection_ty: ecx.tcx().mk_alias_ty(goal.predicate.def_id(), [self_ty]),
|
||||||
term,
|
term,
|
||||||
})
|
}
|
||||||
.to_predicate(tcx),
|
.to_predicate(tcx),
|
||||||
// Technically, we need to check that the future type is Sized,
|
// Technically, we need to check that the future type is Sized,
|
||||||
// but that's already proven by the generator being WF.
|
// but that's already proven by the generator being WF.
|
||||||
@ -490,12 +484,12 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||||||
Self::consider_implied_clause(
|
Self::consider_implied_clause(
|
||||||
ecx,
|
ecx,
|
||||||
goal,
|
goal,
|
||||||
ty::Binder::dummy(ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: ecx
|
projection_ty: ecx
|
||||||
.tcx()
|
.tcx()
|
||||||
.mk_alias_ty(goal.predicate.def_id(), [self_ty, generator.resume_ty()]),
|
.mk_alias_ty(goal.predicate.def_id(), [self_ty, generator.resume_ty()]),
|
||||||
term,
|
term,
|
||||||
})
|
}
|
||||||
.to_predicate(tcx),
|
.to_predicate(tcx),
|
||||||
// Technically, we need to check that the future type is Sized,
|
// Technically, we need to check that the future type is Sized,
|
||||||
// but that's already proven by the generator being WF.
|
// but that's already proven by the generator being WF.
|
||||||
|
@ -857,12 +857,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
ecx.add_goals(
|
ecx.add_goals(
|
||||||
constituent_tys(ecx, goal.predicate.self_ty())?
|
constituent_tys(ecx, goal.predicate.self_ty())?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|ty| {
|
.map(|ty| goal.with(ecx.tcx(), goal.predicate.with_self_ty(ecx.tcx(), ty)))
|
||||||
goal.with(
|
|
||||||
ecx.tcx(),
|
|
||||||
ty::Binder::dummy(goal.predicate.with_self_ty(ecx.tcx(), ty)),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
);
|
);
|
||||||
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||||
@ -905,10 +900,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
let normalizes_to_goal = Goal::new(
|
let normalizes_to_goal = Goal::new(
|
||||||
ecx.tcx(),
|
ecx.tcx(),
|
||||||
param_env,
|
param_env,
|
||||||
ty::Binder::dummy(ty::ProjectionPredicate {
|
ty::ProjectionPredicate { projection_ty, term: normalized_ty.into() },
|
||||||
projection_ty,
|
|
||||||
term: normalized_ty.into(),
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
ecx.add_goal(normalizes_to_goal);
|
ecx.add_goal(normalizes_to_goal);
|
||||||
if let Err(err) = ecx.try_evaluate_added_goals() {
|
if let Err(err) = ecx.try_evaluate_added_goals() {
|
||||||
|
Loading…
Reference in New Issue
Block a user