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 5340288051ac..a1e801e39230 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, AllocError> { - todo!() - } - - unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { - todo!() - } -} - -fn foo() -> impl Iterator { - 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 677b81956f98..6ea238f302f3 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