Skip to content

Commit

Permalink
tolerate region vars in implied bounds
Browse files Browse the repository at this point in the history
See #109628.
  • Loading branch information
aliemjay committed Mar 26, 2023
1 parent b20aa97 commit 2a3177a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_infer/src/infer/outlives/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?})"),
},
}
}
Expand Down
24 changes: 24 additions & 0 deletions tests/ui/implied-bounds/ice-unbound-region-vars.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 2a3177a

Please sign in to comment.