]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/const-param-elided-lifetime.rs
Auto merge of #106503 - cjgillot:remap-nofilter, r=oli-obk
[rust.git] / tests / 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 #![cfg_attr(full, feature(adt_const_params))]
7 #![cfg_attr(full, allow(incomplete_features))]
8
9 struct A<const N: &u8>;
10 //~^ ERROR `&` without an explicit lifetime name cannot be used here
11 //[min]~^^ ERROR `&'static u8` is forbidden
12 trait B {}
13
14 impl<const N: &u8> A<N> {
15 //~^ ERROR `&` without an explicit lifetime name cannot be used here
16 //[min]~^^ ERROR `&'static u8` is forbidden
17     fn foo<const M: &u8>(&self) {}
18     //~^ ERROR `&` without an explicit lifetime name cannot be used here
19     //[min]~^^ ERROR `&'static u8` is forbidden
20 }
21
22 impl<const N: &u8> B for A<N> {}
23 //~^ ERROR `&` without an explicit lifetime name cannot be used here
24 //[min]~^^ ERROR `&'static u8` is forbidden
25
26 fn bar<const N: &u8>() {}
27 //~^ ERROR `&` without an explicit lifetime name cannot be used here
28 //[min]~^^ ERROR `&'static u8` is forbidden
29
30 fn main() {}