]> git.lizzy.rs Git - rust.git/blob - tests/ui/inline-const/const-match-pat-lifetime.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / ui / inline-const / const-match-pat-lifetime.rs
1 // run-pass
2
3 #![allow(incomplete_features)]
4 #![feature(const_mut_refs)]
5 #![feature(inline_const)]
6 #![feature(inline_const_pat)]
7
8 use std::marker::PhantomData;
9
10 // rust-lang/rust#78174: ICE: "cannot convert ReErased to a region vid"
11 fn issue_78174() {
12     match "foo" {
13         const { concat!("fo", "o") } => (),
14         _ => unreachable!(),
15     }
16 }
17
18 #[derive(PartialEq, Eq)]
19 pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
20
21 impl<'a, T: ?Sized> InvariantRef<'a, T> {
22     pub const fn new(r: &'a T) -> Self {
23         InvariantRef(r, PhantomData)
24     }
25 }
26
27 fn match_invariant_ref<'a>() {
28     match const { InvariantRef::<'a, _>::new(&()) } {
29         const { InvariantRef::<'a, ()>::new(&()) } => {
30         }
31     }
32 }
33
34 fn main() {
35     issue_78174();
36     match_invariant_ref();
37 }