tolerate region vars in implied bounds

See https://github.com/rust-lang/rust/issues/109628.
This commit is contained in:
Ali MJ Al-Nasrawy 2023-03-26 14:37:24 +03:00
parent b20aa97d48
commit 2a3177a8bc
2 changed files with 28 additions and 1 deletions

View file

@ -142,7 +142,10 @@ impl<'tcx> OutlivesEnvironmentBuilder<'tcx> {
ty::ReStatic | ty::ReEarlyBound(_) | ty::ReFree(_),
) => self.region_relation.add(r_a, r_b),
(ty::ReError(_), _) | (_, ty::ReError(_)) => {}
_ => bug!("add_outlives_bounds: unexpected regions"),
// FIXME(#109628): We shouldn't have existential variables in implied bounds.
// Panic here once the linked issue is resolved!
(ty::ReVar(_), _) | (_, ty::ReVar(_)) => {}
_ => bug!("add_outlives_bounds: unexpected regions: ({r_a:?}, {r_b:?})"),
},
}
}

View file

@ -0,0 +1,24 @@
// Because of #109628, we can have unbounded region vars in implied bounds.
// Make sure we don't ICE in this case!
//
// check-pass
pub trait MapAccess {
type Error;
fn next_key_seed(&mut self) -> Option<Self::Error>;
}
struct Access<'a> {
_marker: std::marker::PhantomData<&'a ()>,
}
// implied_bounds(Option<Self::Error>) = ['?1: 'a, ]
// where '?1 is a fresh region var.
impl<'a, 'b: 'a> MapAccess for Access<'a> {
type Error = ();
fn next_key_seed(&mut self) -> Option<Self::Error> {
unimplemented!()
}
}
fn main() {}