reviews + rebase
This commit is contained in:
parent
b181a12623
commit
f867742be8
11 changed files with 101 additions and 114 deletions
|
@ -59,7 +59,9 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
|
|||
|
||||
ty::Closure(_, args) => Ok(vec![ty::Binder::dummy(args.as_closure().tupled_upvars_ty())]),
|
||||
|
||||
ty::CoroutineClosure(_, args) => Ok(vec![args.as_coroutine_closure().tupled_upvars_ty()]),
|
||||
ty::CoroutineClosure(_, args) => {
|
||||
Ok(vec![ty::Binder::dummy(args.as_coroutine_closure().tupled_upvars_ty())])
|
||||
}
|
||||
|
||||
ty::Coroutine(_, args) => {
|
||||
let coroutine_args = args.as_coroutine();
|
||||
|
|
|
@ -480,7 +480,6 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
|||
self.infcx.enter_forall(kind, |kind| {
|
||||
let goal = goal.with(self.tcx(), ty::Binder::dummy(kind));
|
||||
self.add_goal(GoalSource::Misc, goal);
|
||||
// FIXME(tree_universes): leaking universes
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ impl<'tcx> InferCtxtSelectExt<'tcx> for InferCtxt<'tcx> {
|
|||
) -> SelectionResult<'tcx, Selection<'tcx>> {
|
||||
assert!(self.next_trait_solver());
|
||||
|
||||
// FIXME(tree_universes): leaking universes?
|
||||
self.enter_forall(obligation.predicate, |pred| {
|
||||
let trait_goal = Goal::new(self.tcx, obligation.param_env, pred);
|
||||
|
||||
|
|
|
@ -1060,7 +1060,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
constituent_tys(ecx, goal.predicate.self_ty())?
|
||||
.into_iter()
|
||||
.map(|ty| {
|
||||
// FIXME(tree_universes): leaking universes
|
||||
ecx.enter_forall(ty, |ty| {
|
||||
goal.with(ecx.tcx(), goal.predicate.with_self_ty(ecx.tcx(), ty))
|
||||
})
|
||||
|
|
|
@ -4621,7 +4621,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let ocx = ObligationCtxt::new(self);
|
||||
self.enter_forall(pred, |pred| {
|
||||
let pred = ocx.normalize(&ObligationCause::dummy(), param_env, pred);
|
||||
// FIXME(tree_universes): universe leakage
|
||||
ocx.register_obligation(Obligation::new(
|
||||
self.tcx,
|
||||
ObligationCause::dummy(),
|
||||
|
|
|
@ -2049,7 +2049,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
for (obligation_arg, impl_arg) in
|
||||
std::iter::zip(obligation_trait_ref.args, impl_trait_ref.args)
|
||||
{
|
||||
// FIXME(tree_universes): universe leakage
|
||||
if let Err(terr) =
|
||||
ocx.eq(&ObligationCause::dummy(), param_env, impl_arg, obligation_arg)
|
||||
{
|
||||
|
|
|
@ -728,64 +728,63 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
self.infcx.probe(|_snapshot| {
|
||||
let poly_trait_predicate = self.infcx.resolve_vars_if_possible(obligation.predicate);
|
||||
let placeholder_trait_predicate =
|
||||
self.infcx.enter_forall_and_leak_universe(poly_trait_predicate);
|
||||
|
||||
let self_ty = placeholder_trait_predicate.self_ty();
|
||||
let principal_trait_ref = match self_ty.kind() {
|
||||
ty::Dynamic(data, ..) => {
|
||||
if data.auto_traits().any(|did| did == obligation.predicate.def_id()) {
|
||||
debug!(
|
||||
"assemble_candidates_from_object_ty: matched builtin bound, \
|
||||
self.infcx.enter_forall(poly_trait_predicate, |placeholder_trait_predicate| {
|
||||
let self_ty = placeholder_trait_predicate.self_ty();
|
||||
let principal_trait_ref = match self_ty.kind() {
|
||||
ty::Dynamic(data, ..) => {
|
||||
if data.auto_traits().any(|did| did == obligation.predicate.def_id()) {
|
||||
debug!(
|
||||
"assemble_candidates_from_object_ty: matched builtin bound, \
|
||||
pushing candidate"
|
||||
);
|
||||
candidates.vec.push(BuiltinObjectCandidate);
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(principal) = data.principal() {
|
||||
if !self.infcx.tcx.features().object_safe_for_dispatch {
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
} else if self.tcx().check_is_object_safe(principal.def_id()) {
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
} else {
|
||||
);
|
||||
candidates.vec.push(BuiltinObjectCandidate);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Only auto trait bounds exist.
|
||||
|
||||
if let Some(principal) = data.principal() {
|
||||
if !self.infcx.tcx.features().object_safe_for_dispatch {
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
} else if self.tcx().check_is_object_safe(principal.def_id()) {
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Only auto trait bounds exist.
|
||||
return;
|
||||
}
|
||||
}
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_candidates_from_object_ty: ambiguous");
|
||||
candidates.ambiguous = true; // could wind up being an object type
|
||||
return;
|
||||
}
|
||||
}
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_candidates_from_object_ty: ambiguous");
|
||||
candidates.ambiguous = true; // could wind up being an object type
|
||||
return;
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
_ => return,
|
||||
};
|
||||
|
||||
debug!(?principal_trait_ref, "assemble_candidates_from_object_ty");
|
||||
debug!(?principal_trait_ref, "assemble_candidates_from_object_ty");
|
||||
|
||||
// Count only those upcast versions that match the trait-ref
|
||||
// we are looking for. Specifically, do not only check for the
|
||||
// correct trait, but also the correct type parameters.
|
||||
// For example, we may be trying to upcast `Foo` to `Bar<i32>`,
|
||||
// but `Foo` is declared as `trait Foo: Bar<u32>`.
|
||||
let candidate_supertraits = util::supertraits(self.tcx(), principal_trait_ref)
|
||||
.enumerate()
|
||||
.filter(|&(_, upcast_trait_ref)| {
|
||||
self.infcx.probe(|_| {
|
||||
self.match_normalize_trait_ref(
|
||||
obligation,
|
||||
upcast_trait_ref,
|
||||
placeholder_trait_predicate.trait_ref,
|
||||
)
|
||||
.is_ok()
|
||||
// Count only those upcast versions that match the trait-ref
|
||||
// we are looking for. Specifically, do not only check for the
|
||||
// correct trait, but also the correct type parameters.
|
||||
// For example, we may be trying to upcast `Foo` to `Bar<i32>`,
|
||||
// but `Foo` is declared as `trait Foo: Bar<u32>`.
|
||||
let candidate_supertraits = util::supertraits(self.tcx(), principal_trait_ref)
|
||||
.enumerate()
|
||||
.filter(|&(_, upcast_trait_ref)| {
|
||||
self.infcx.probe(|_| {
|
||||
self.match_normalize_trait_ref(
|
||||
obligation,
|
||||
upcast_trait_ref,
|
||||
placeholder_trait_predicate.trait_ref,
|
||||
)
|
||||
.is_ok()
|
||||
})
|
||||
})
|
||||
})
|
||||
.map(|(idx, _)| ObjectCandidate(idx));
|
||||
.map(|(idx, _)| ObjectCandidate(idx));
|
||||
|
||||
candidates.vec.extend(candidate_supertraits);
|
||||
candidates.vec.extend(candidate_supertraits);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue