Eagerly instantiate opaque types
This commit is contained in:
parent
689a868a1f
commit
5c46002273
1 changed files with 4 additions and 6 deletions
|
@ -551,14 +551,16 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
||||||
let predicate = predicate.subst(tcx, substs);
|
let predicate = predicate.subst(tcx, substs);
|
||||||
debug!(?predicate);
|
debug!(?predicate);
|
||||||
|
|
||||||
// Replace all other mentions of the same opaque type with the hidden type,
|
|
||||||
// as the bounds must hold on the hidden type after all.
|
|
||||||
let predicate = predicate.fold_with(&mut BottomUpFolder {
|
let predicate = predicate.fold_with(&mut BottomUpFolder {
|
||||||
tcx,
|
tcx,
|
||||||
ty_op: |ty| match *ty.kind() {
|
ty_op: |ty| match *ty.kind() {
|
||||||
|
// Replace all other mentions of the same opaque type with the hidden type,
|
||||||
|
// as the bounds must hold on the hidden type after all.
|
||||||
ty::Opaque(def_id2, substs2) if def_id == def_id2 && substs == substs2 => {
|
ty::Opaque(def_id2, substs2) if def_id == def_id2 && substs == substs2 => {
|
||||||
ty_var
|
ty_var
|
||||||
}
|
}
|
||||||
|
// Instantiate nested instances of `impl Trait`.
|
||||||
|
ty::Opaque(..) => self.instantiate_opaque_types_in_map(ty),
|
||||||
_ => ty,
|
_ => ty,
|
||||||
},
|
},
|
||||||
lt_op: |lt| lt,
|
lt_op: |lt| lt,
|
||||||
|
@ -589,10 +591,6 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
||||||
return tcx.ty_error();
|
return tcx.ty_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Change the predicate to refer to the type variable,
|
|
||||||
// which will be the concrete type instead of the opaque type.
|
|
||||||
// This also instantiates nested instances of `impl Trait`.
|
|
||||||
let predicate = self.instantiate_opaque_types_in_map(predicate);
|
|
||||||
|
|
||||||
let cause =
|
let cause =
|
||||||
traits::ObligationCause::new(self.value_span, self.body_id, traits::OpaqueType);
|
traits::ObligationCause::new(self.value_span, self.body_id, traits::OpaqueType);
|
||||||
|
|
Loading…
Add table
Reference in a new issue