diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-08-25 00:42:34 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-08-25 00:42:34 +0900 |
| commit | c57ecfae0e131d14676e6d1aa535cb8f17dba80b (patch) | |
| tree | 4701993252b3d2f8f0c2d0d592ad3dedfcf8430a | |
| parent | 3855e039a2c095f2e54b2f389f29e200293774ac (diff) | |
| download | rust-c57ecfae0e131d14676e6d1aa535cb8f17dba80b.tar.gz rust-c57ecfae0e131d14676e6d1aa535cb8f17dba80b.zip | |
use a minimized example
| -rw-r--r-- | src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.rs | 29 | ||||
| -rw-r--r-- | src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr | 16 |
2 files changed, 14 insertions, 31 deletions
diff --git a/src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.rs b/src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.rs index 5340288051a..a1e801e3923 100644 --- a/src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.rs +++ b/src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.rs @@ -1,29 +1,12 @@ -#![feature(allocator_api)] +pub trait T {} -use std::{ - alloc::{AllocError, Allocator, Layout}, - ptr::NonNull, -}; +struct S<'a>(&'a ()); -struct GhostBump; +impl<'a> T for S<'a> {} -unsafe impl Allocator for &GhostBump { - fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { - todo!() - } - - unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { - todo!() - } -} - -fn foo() -> impl Iterator<Item = usize> { - let arena = GhostBump; - let mut vec = Vec::new_in(&arena); //~ ERROR `arena` does not live long enough - vec.push(1); - vec.push(2); - vec.push(3); - vec.into_iter() +fn foo() -> impl T { + let x = (); + S(&x) //~ ERROR `x` does not live long enough } fn main() {} diff --git a/src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr b/src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr index 677b81956f9..6ea238f302f 100644 --- a/src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr +++ b/src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr @@ -1,13 +1,13 @@ -error[E0597]: `arena` does not live long enough - --> $DIR/do-not-suggest-adding-bound-to-opaque-type.rs:22:31 +error[E0597]: `x` does not live long enough + --> $DIR/do-not-suggest-adding-bound-to-opaque-type.rs:9:7 | -LL | let mut vec = Vec::new_in(&arena); - | ^^^^^^ borrowed value does not live long enough -... -LL | vec.into_iter() - | --------------- opaque type requires that `arena` is borrowed for `'static` +LL | S(&x) + | --^^- + | | | + | | borrowed value does not live long enough + | opaque type requires that `x` is borrowed for `'static` LL | } - | - `arena` dropped here while still borrowed + | - `x` dropped here while still borrowed error: aborting due to previous error |
