]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/generic-slice.rs
Rollup merge of #104076 - ozkanonur:fix-ci-rustc-sysroot, r=jyn514
[rust.git] / src / test / ui / consts / const-eval / generic-slice.rs
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() {}