use a minimized example
This commit is contained in:
parent
3855e039a2
commit
c57ecfae0e
2 changed files with 14 additions and 31 deletions
|
@ -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() {}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue