In relate_tys, when creating new universes, insert missing universes as other

This commit is contained in:
jackh726 2021-09-09 18:04:59 -04:00
parent 497ee321af
commit 0a3c6bb887
2 changed files with 43 additions and 3 deletions

View File

@ -80,10 +80,15 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
}
fn create_next_universe(&mut self) -> ty::UniverseIndex {
let info_universe =
self.borrowck_context.constraints.universe_causes.push(self.universe_info.clone());
let universe = self.infcx.create_next_universe();
assert_eq!(info_universe, universe);
// FIXME: If we relate tys after normalizing with late-bound regions, there will
// be extra universes. A proper solution would be to somehow track those universes
// during projection, but here we just treat those as "other"
self.borrowck_context
.constraints
.universe_causes
.ensure_contains_elem(universe, || UniverseInfo::other());
self.borrowck_context.constraints.universe_causes[universe] = self.universe_info.clone();
universe
}

View File

@ -0,0 +1,35 @@
// check-pass
trait Yokeable<'a> {
type Output: 'a;
}
impl<'a> Yokeable<'a> for () {
type Output = ();
}
trait DataMarker<'data> {
type Yokeable: for<'a> Yokeable<'a>;
}
impl<'data> DataMarker<'data> for () {
type Yokeable = ();
}
struct DataPayload<'data, M>(&'data M);
impl DataPayload<'static, ()> {
pub fn map_project_with_capture<M2, T>(
_: for<'a> fn(
capture: T,
std::marker::PhantomData<&'a ()>,
) -> <M2::Yokeable as Yokeable<'a>>::Output,
) -> DataPayload<'static, M2>
where
M2: DataMarker<'static>,
{
todo!()
}
}
fn main() {
let _: DataPayload<()> = DataPayload::<()>::map_project_with_capture::<_, &()>(|_, _| todo!());
}