diff options
| author | lcnr <rust@lcnr.de> | 2024-12-06 15:03:13 +0100 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2024-12-18 16:05:44 +0100 |
| commit | 4d5aaa0f30534943847c84eaf7baffa7fbb9cfe6 (patch) | |
| tree | 2c7a15f989e28410aecbf33d29bed2c0df9f2edd /tests | |
| parent | 085d93181093c1daf9ef595cd08d73633062e635 (diff) | |
| download | rust-4d5aaa0f30534943847c84eaf7baffa7fbb9cfe6.tar.gz rust-4d5aaa0f30534943847c84eaf7baffa7fbb9cfe6.zip | |
fix crashes
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/crashes/124021.rs | 6 | ||||
| -rw-r--r-- | tests/ui/borrowck/overwrite-anon-late-param-regions.rs | 15 | ||||
| -rw-r--r-- | tests/ui/borrowck/overwrite-anon-late-param-regions.stderr | 21 |
3 files changed, 36 insertions, 6 deletions
diff --git a/tests/crashes/124021.rs b/tests/crashes/124021.rs deleted file mode 100644 index a2b6b7f9a66..00000000000 --- a/tests/crashes/124021.rs +++ /dev/null @@ -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 -} diff --git a/tests/ui/borrowck/overwrite-anon-late-param-regions.rs b/tests/ui/borrowck/overwrite-anon-late-param-regions.rs new file mode 100644 index 00000000000..7b0f784068f --- /dev/null +++ b/tests/ui/borrowck/overwrite-anon-late-param-regions.rs @@ -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() {} diff --git a/tests/ui/borrowck/overwrite-anon-late-param-regions.stderr b/tests/ui/borrowck/overwrite-anon-late-param-regions.stderr new file mode 100644 index 00000000000..c5b7284271e --- /dev/null +++ b/tests/ui/borrowck/overwrite-anon-late-param-regions.stderr @@ -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`. |
