Skip to content

Commit 7a65fe3

Browse files
Add test cases for #64945
This also tests that `&&[]` no longer causes an ICE in this PR (although the test fails the borrow checker). This could be more complete.
1 parent 8d84646 commit 7a65fe3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Several variants of #64945.
2+
3+
// This struct is not important, we just use it to put `T` and `'a` in scope for our associated
4+
// consts.
5+
struct Generic<'a, T>(std::marker::PhantomData<&'a T>);
6+
7+
impl<'a, T: 'static> Generic<'a, T> {
8+
const EMPTY_SLICE: &'a [T] = {
9+
let x: &'a [T] = &[];
10+
x
11+
};
12+
13+
const EMPTY_SLICE_REF: &'a &'static [T] = {
14+
let x: &'static [T] = &[];
15+
&x
16+
//~^ ERROR `x` does not live long enough
17+
};
18+
}
19+
20+
static mut INTERIOR_MUT_AND_DROP: &'static [std::cell::RefCell<Vec<i32>>] = {
21+
let x: &[_] = &[];
22+
x
23+
};
24+
25+
static mut INTERIOR_MUT_AND_DROP_REF: &'static &'static [std::cell::RefCell<Vec<i32>>] = {
26+
let x: &[_] = &[];
27+
&x
28+
//~^ ERROR `x` does not live long enough
29+
};
30+
31+
fn main() {}

0 commit comments

Comments
 (0)