Skip to content

Commit c57ecfa

Browse files
committed
use a minimized example
1 parent 3855e03 commit c57ecfa

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
1-
#![feature(allocator_api)]
1+
pub trait T {}
22

3-
use std::{
4-
alloc::{AllocError, Allocator, Layout},
5-
ptr::NonNull,
6-
};
3+
struct S<'a>(&'a ());
74

8-
struct GhostBump;
5+
impl<'a> T for S<'a> {}
96

10-
unsafe impl Allocator for &GhostBump {
11-
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
12-
todo!()
13-
}
14-
15-
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
16-
todo!()
17-
}
18-
}
19-
20-
fn foo() -> impl Iterator<Item = usize> {
21-
let arena = GhostBump;
22-
let mut vec = Vec::new_in(&arena); //~ ERROR `arena` does not live long enough
23-
vec.push(1);
24-
vec.push(2);
25-
vec.push(3);
26-
vec.into_iter()
7+
fn foo() -> impl T {
8+
let x = ();
9+
S(&x) //~ ERROR `x` does not live long enough
2710
}
2811

2912
fn main() {}

src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
error[E0597]: `arena` does not live long enough
2-
--> $DIR/do-not-suggest-adding-bound-to-opaque-type.rs:22:31
1+
error[E0597]: `x` does not live long enough
2+
--> $DIR/do-not-suggest-adding-bound-to-opaque-type.rs:9:7
33
|
4-
LL | let mut vec = Vec::new_in(&arena);
5-
| ^^^^^^ borrowed value does not live long enough
6-
...
7-
LL | vec.into_iter()
8-
| --------------- opaque type requires that `arena` is borrowed for `'static`
4+
LL | S(&x)
5+
| --^^-
6+
| | |
7+
| | borrowed value does not live long enough
8+
| opaque type requires that `x` is borrowed for `'static`
99
LL | }
10-
| - `arena` dropped here while still borrowed
10+
| - `x` dropped here while still borrowed
1111

1212
error: aborting due to previous error
1313

0 commit comments

Comments
 (0)