Skip to content

Commit 0a3c6bb

Browse files
committed
In relate_tys, when creating new universes, insert missing universes as other
1 parent 497ee32 commit 0a3c6bb

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

Diff for: compiler/rustc_borrowck/src/type_check/relate_tys.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,15 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
8080
}
8181

8282
fn create_next_universe(&mut self) -> ty::UniverseIndex {
83-
let info_universe =
84-
self.borrowck_context.constraints.universe_causes.push(self.universe_info.clone());
8583
let universe = self.infcx.create_next_universe();
86-
assert_eq!(info_universe, universe);
84+
// FIXME: If we relate tys after normalizing with late-bound regions, there will
85+
// be extra universes. A proper solution would be to somehow track those universes
86+
// during projection, but here we just treat those as "other"
87+
self.borrowck_context
88+
.constraints
89+
.universe_causes
90+
.ensure_contains_elem(universe, || UniverseInfo::other());
91+
self.borrowck_context.constraints.universe_causes[universe] = self.universe_info.clone();
8792
universe
8893
}
8994

Diff for: src/test/ui/hrtb/issue-88446.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// check-pass
2+
3+
trait Yokeable<'a> {
4+
type Output: 'a;
5+
}
6+
impl<'a> Yokeable<'a> for () {
7+
type Output = ();
8+
}
9+
10+
trait DataMarker<'data> {
11+
type Yokeable: for<'a> Yokeable<'a>;
12+
}
13+
impl<'data> DataMarker<'data> for () {
14+
type Yokeable = ();
15+
}
16+
17+
struct DataPayload<'data, M>(&'data M);
18+
19+
impl DataPayload<'static, ()> {
20+
pub fn map_project_with_capture<M2, T>(
21+
_: for<'a> fn(
22+
capture: T,
23+
std::marker::PhantomData<&'a ()>,
24+
) -> <M2::Yokeable as Yokeable<'a>>::Output,
25+
) -> DataPayload<'static, M2>
26+
where
27+
M2: DataMarker<'static>,
28+
{
29+
todo!()
30+
}
31+
}
32+
33+
fn main() {
34+
let _: DataPayload<()> = DataPayload::<()>::map_project_with_capture::<_, &()>(|_, _| todo!());
35+
}

0 commit comments

Comments
 (0)