Skip to content

Commit 2a3177a

Browse files
committed
tolerate region vars in implied bounds
See #109628.
1 parent b20aa97 commit 2a3177a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Diff for: compiler/rustc_infer/src/infer/outlives/env.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ impl<'tcx> OutlivesEnvironmentBuilder<'tcx> {
142142
ty::ReStatic | ty::ReEarlyBound(_) | ty::ReFree(_),
143143
) => self.region_relation.add(r_a, r_b),
144144
(ty::ReError(_), _) | (_, ty::ReError(_)) => {}
145-
_ => bug!("add_outlives_bounds: unexpected regions"),
145+
// FIXME(#109628): We shouldn't have existential variables in implied bounds.
146+
// Panic here once the linked issue is resolved!
147+
(ty::ReVar(_), _) | (_, ty::ReVar(_)) => {}
148+
_ => bug!("add_outlives_bounds: unexpected regions: ({r_a:?}, {r_b:?})"),
146149
},
147150
}
148151
}

Diff for: tests/ui/implied-bounds/ice-unbound-region-vars.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Because of #109628, we can have unbounded region vars in implied bounds.
2+
// Make sure we don't ICE in this case!
3+
//
4+
// check-pass
5+
6+
pub trait MapAccess {
7+
type Error;
8+
fn next_key_seed(&mut self) -> Option<Self::Error>;
9+
}
10+
11+
struct Access<'a> {
12+
_marker: std::marker::PhantomData<&'a ()>,
13+
}
14+
15+
// implied_bounds(Option<Self::Error>) = ['?1: 'a, ]
16+
// where '?1 is a fresh region var.
17+
impl<'a, 'b: 'a> MapAccess for Access<'a> {
18+
type Error = ();
19+
fn next_key_seed(&mut self) -> Option<Self::Error> {
20+
unimplemented!()
21+
}
22+
}
23+
24+
fn main() {}

0 commit comments

Comments
 (0)