Skip to content

Commit 2f89aef

Browse files
committed
Do not subst nonexistent lifetime in RPIT in recursive function
1 parent 578bcbc commit 2f89aef

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
8888
Some(region) => {
8989
let vid = self.universal_regions.to_region_vid(region);
9090
subst_regions.push(vid);
91-
region
91+
Some(region)
9292
}
9393
None => {
9494
subst_regions.push(vid);
95-
ty::Region::new_error_with_message(
96-
infcx.tcx,
97-
concrete_type.span,
98-
"opaque type with non-universal region substs",
99-
)
95+
None
10096
}
10197
}
10298
};
@@ -118,7 +114,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
118114
return region;
119115
}
120116
let vid = self.to_region_vid(region);
121-
to_universal_region(vid, &mut subst_regions)
117+
to_universal_region(vid, &mut subst_regions).unwrap_or(region)
122118
});
123119
debug!(?universal_substs);
124120
debug!(?subst_regions);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
3+
#![allow(unconditional_recursion)]
4+
5+
fn test<'a>() -> impl Sized + 'a {
6+
let r: i32 = test();
7+
r
8+
}
9+
10+
fn main() {}

0 commit comments

Comments
 (0)