fix crashes
This commit is contained in:
parent
085d931810
commit
4d5aaa0f30
4 changed files with 37 additions and 7 deletions
|
@ -2230,7 +2230,7 @@ impl<'tcx> RegionDefinition<'tcx> {
|
||||||
fn new(universe: ty::UniverseIndex, rv_origin: RegionVariableOrigin) -> Self {
|
fn new(universe: ty::UniverseIndex, rv_origin: RegionVariableOrigin) -> Self {
|
||||||
// Create a new region definition. Note that, for free
|
// Create a new region definition. Note that, for free
|
||||||
// regions, the `external_name` field gets updated later in
|
// regions, the `external_name` field gets updated later in
|
||||||
// `init_universal_regions`.
|
// `init_free_and_bound_regions`.
|
||||||
|
|
||||||
let origin = match rv_origin {
|
let origin = match rv_origin {
|
||||||
RegionVariableOrigin::Nll(origin) => origin,
|
RegionVariableOrigin::Nll(origin) => origin,
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
//@ known-bug: #124021
|
|
||||||
type Opaque2<'a> = impl Sized + 'a;
|
|
||||||
|
|
||||||
fn test2() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque2<'a>, Opaque2<'a>) {
|
|
||||||
|x| x
|
|
||||||
}
|
|
15
tests/ui/borrowck/overwrite-anon-late-param-regions.rs
Normal file
15
tests/ui/borrowck/overwrite-anon-late-param-regions.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// A regression test for #124021. When liberating the late bound regions here
|
||||||
|
// we encounter multiple `LateBoundRegion::Anon`. These ended up resulting in
|
||||||
|
// distinct nll vars, but mapped to the same `RegionKind::LateParam`. This
|
||||||
|
// then caused an ICE when trying to fetch lazily computed information for the
|
||||||
|
// nll var of an overwritten liberated bound region.
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
|
type Opaque2<'a> = impl Sized + 'a;
|
||||||
|
|
||||||
|
fn test2() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque2<'a>, Opaque2<'a>) {
|
||||||
|
|x| x
|
||||||
|
//~^ ERROR lifetime may not live long enough
|
||||||
|
//~| ERROR expected generic lifetime parameter, found `'a`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
21
tests/ui/borrowck/overwrite-anon-late-param-regions.stderr
Normal file
21
tests/ui/borrowck/overwrite-anon-late-param-regions.stderr
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
error: lifetime may not live long enough
|
||||||
|
--> $DIR/overwrite-anon-late-param-regions.rs:10:9
|
||||||
|
|
|
||||||
|
LL | |x| x
|
||||||
|
| - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
||||||
|
| |
|
||||||
|
| has type `(&str, &'1 str)`
|
||||||
|
| has type `(&'2 str, &str)`
|
||||||
|
|
||||||
|
error[E0792]: expected generic lifetime parameter, found `'a`
|
||||||
|
--> $DIR/overwrite-anon-late-param-regions.rs:10:5
|
||||||
|
|
|
||||||
|
LL | type Opaque2<'a> = impl Sized + 'a;
|
||||||
|
| -- this generic parameter must be used with a generic lifetime parameter
|
||||||
|
...
|
||||||
|
LL | |x| x
|
||||||
|
| ^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0792`.
|
Loading…
Add table
Add a link
Reference in a new issue