3 #![allow(incomplete_features)]
4 #![feature(const_mut_refs)]
5 #![feature(inline_const_pat)]
7 use std::marker::PhantomData;
9 #[derive(PartialEq, Eq)]
10 pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
12 impl<'a, T: ?Sized> InvariantRef<'a, T> {
13 pub const fn new(r: &'a T) -> Self {
14 InvariantRef(r, PhantomData)
18 impl<'a> InvariantRef<'a, ()> {
19 pub const NEW: Self = InvariantRef::new(&());
22 fn match_invariant_ref<'a>() {
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
28 const { InvariantRef::<'a>::NEW } => (),
33 match_invariant_ref();