Skip to content

Commit 4d5aaa0

Browse files
committed
fix crashes
1 parent 085d931 commit 4d5aaa0

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

Diff for: compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ impl<'tcx> RegionDefinition<'tcx> {
22302230
fn new(universe: ty::UniverseIndex, rv_origin: RegionVariableOrigin) -> Self {
22312231
// Create a new region definition. Note that, for free
22322232
// regions, the `external_name` field gets updated later in
2233-
// `init_universal_regions`.
2233+
// `init_free_and_bound_regions`.
22342234

22352235
let origin = match rv_origin {
22362236
RegionVariableOrigin::Nll(origin) => origin,

Diff for: tests/crashes/124021.rs

-6
This file was deleted.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// A regression test for #124021. When liberating the late bound regions here
2+
// we encounter multiple `LateBoundRegion::Anon`. These ended up resulting in
3+
// distinct nll vars, but mapped to the same `RegionKind::LateParam`. This
4+
// then caused an ICE when trying to fetch lazily computed information for the
5+
// nll var of an overwritten liberated bound region.
6+
#![feature(type_alias_impl_trait)]
7+
type Opaque2<'a> = impl Sized + 'a;
8+
9+
fn test2() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque2<'a>, Opaque2<'a>) {
10+
|x| x
11+
//~^ ERROR lifetime may not live long enough
12+
//~| ERROR expected generic lifetime parameter, found `'a`
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/overwrite-anon-late-param-regions.rs:10:9
3+
|
4+
LL | |x| x
5+
| - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
6+
| |
7+
| has type `(&str, &'1 str)`
8+
| has type `(&'2 str, &str)`
9+
10+
error[E0792]: expected generic lifetime parameter, found `'a`
11+
--> $DIR/overwrite-anon-late-param-regions.rs:10:5
12+
|
13+
LL | type Opaque2<'a> = impl Sized + 'a;
14+
| -- this generic parameter must be used with a generic lifetime parameter
15+
...
16+
LL | |x| x
17+
| ^^^^^
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0792`.

0 commit comments

Comments
 (0)