1
Fork 0

Rollup merge of #120707 - compiler-errors:suitable-region, r=nnethercote

Don't expect early-bound region to be local when reporting errors in RPITIT well-formedness

The implicit lifetime in the example code gets replaced with `ReError`, which fails a `sub_regions` check in the lexical region solver. Error reporting ends up calling `is_suitable_region` on an early bound region in the *trait* definition. This causes an ICE because we `expect_local()`.

This is kind of a bad explanation, but this code just makes diagnostics reporting a bit more gracefully fallible. If the reviewer wants a thorough investigation of exactly where we get this region outlives obligation, I can write one up. Doesn't really seem worth it, though, imo.

Fixes #120638
Fixes #120648
This commit is contained in:
Matthias Krüger 2024-02-06 22:45:43 +01:00 committed by GitHub
commit 84114fea9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 1 deletions

View file

@ -1193,7 +1193,7 @@ impl<'tcx> TyCtxt<'tcx> {
let (suitable_region_binding_scope, bound_region) = loop {
let def_id = match region.kind() {
ty::ReLateParam(fr) => fr.bound_region.get_id()?.as_local()?,
ty::ReEarlyParam(ebr) => ebr.def_id.expect_local(),
ty::ReEarlyParam(ebr) => ebr.def_id.as_local()?,
_ => return None, // not a free region
};
let scope = self.local_parent(def_id);