]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const-param-elided-lifetime.rs
Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se
[rust.git] / src / test / ui / const-generics / const-param-elided-lifetime.rs
1 // Elided lifetimes within the type of a const generic parameters is disallowed. This matches the
2 // behaviour of trait bounds where `fn foo<T: Ord<&u8>>() {}` is illegal. Though we could change
3 // elided lifetimes within the type of a const generic parameters to be 'static, like elided
4 // lifetimes within const/static items.
5 // revisions: full min
6
7 #![cfg_attr(full, feature(const_generics))]
8 #![cfg_attr(full, allow(incomplete_features))]
9
10 struct A<const N: &u8>;
11 //~^ ERROR `&` without an explicit lifetime name cannot be used here
12 //[min]~^^ ERROR `&'static u8` is forbidden
13 trait B {}
14
15 impl<const N: &u8> A<N> {
16 //~^ ERROR `&` without an explicit lifetime name cannot be used here
17 //[min]~^^ ERROR `&'static u8` is forbidden
18     fn foo<const M: &u8>(&self) {}
19     //~^ ERROR `&` without an explicit lifetime name cannot be used here
20     //[min]~^^ ERROR `&'static u8` is forbidden
21 }
22
23 impl<const N: &u8> B for A<N> {}
24 //~^ ERROR `&` without an explicit lifetime name cannot be used here
25 //[min]~^^ ERROR `&'static u8` is forbidden
26
27 fn bar<const N: &u8>() {}
28 //~^ ERROR `&` without an explicit lifetime name cannot be used here
29 //[min]~^^ ERROR `&'static u8` is forbidden
30
31 fn main() {}