]> git.lizzy.rs Git - rust.git/blob - tests/ui/inline-const/const-match-pat-lifetime-err.rs
Rollup merge of #107204 - euclio:assoc-const-suggestion, r=petrochenkov
[rust.git] / tests / ui / inline-const / const-match-pat-lifetime-err.rs
1 // ignore-test
2
3 #![allow(incomplete_features)]
4 #![feature(const_mut_refs)]
5 #![feature(inline_const_pat)]
6
7 use std::marker::PhantomData;
8
9 #[derive(PartialEq, Eq)]
10 pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
11
12 impl<'a, T: ?Sized> InvariantRef<'a, T> {
13     pub const fn new(r: &'a T) -> Self {
14         InvariantRef(r, PhantomData)
15     }
16 }
17
18 impl<'a> InvariantRef<'a, ()> {
19     pub const NEW: Self = InvariantRef::new(&());
20 }
21
22 fn match_invariant_ref<'a>() {
23     let y = ();
24     match InvariantRef::new(&y) {
25     //~^ ERROR `y` does not live long enough [E0597]
26         // FIXME(nbdd0121): This should give the same error as `InvariantRef::<'a>::NEW` (without
27         // const block)
28         const { InvariantRef::<'a>::NEW } => (),
29     }
30 }
31
32 fn main() {
33     match_invariant_ref();
34 }