diff options
| author | Michael Goulet <michael@errs.io> | 2022-10-22 02:48:36 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-10-22 03:00:58 +0000 |
| commit | e025306fa050ac593bff366eb1c9bff7bfd00b1d (patch) | |
| tree | fe2e5f5e3a57dbd6c09e4b493ab976b203886302 /src/test/ui | |
| parent | 0940040c0486a536be4f8685c7dd9a078f9e87c2 (diff) | |
Don't ICE on regions from anonymous_lifetime_in_impl_trait
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/borrowck/anonymous-region-in-apit.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/borrowck/anonymous-region-in-apit.stderr | 16 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/anonymous-region-in-apit.rs b/src/test/ui/borrowck/anonymous-region-in-apit.rs new file mode 100644 index 00000000000..7799a7cb151 --- /dev/null +++ b/src/test/ui/borrowck/anonymous-region-in-apit.rs @@ -0,0 +1,12 @@ +#![feature(anonymous_lifetime_in_impl_trait)] + +trait Foo<T> { + fn bar(self, baz: T); +} + +fn qux(foo: impl Foo<&str>) { + |baz: &str| foo.bar(baz); + //~^ ERROR borrowed data escapes outside of closure +} + +fn main() {} diff --git a/src/test/ui/borrowck/anonymous-region-in-apit.stderr b/src/test/ui/borrowck/anonymous-region-in-apit.stderr new file mode 100644 index 00000000000..9e100f8ac3c --- /dev/null +++ b/src/test/ui/borrowck/anonymous-region-in-apit.stderr @@ -0,0 +1,16 @@ +error[E0521]: borrowed data escapes outside of closure + --> $DIR/anonymous-region-in-apit.rs:8:17 + | +LL | fn qux(foo: impl Foo<&str>) { + | --- lifetime `'2` appears in the type of `foo` +LL | |baz: &str| foo.bar(baz); + | --- - ^^^^^^^^^^^^ + | | | | + | | | `baz` escapes the closure body here + | | | argument requires that `'1` must outlive `'2` + | | let's call the lifetime of this reference `'1` + | `baz` is a reference that is only valid in the closure body + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0521`. |
