]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const-param-elided-lifetime.rs
pin docs: add some forward references
[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
6 #![feature(const_generics)]
7 //~^ WARN the feature `const_generics` is incomplete
8
9 struct A<const N: &u8>;
10 //~^ ERROR `&` without an explicit lifetime name cannot be used here
11 trait B {}
12
13 impl<const N: &u8> A<N> { //~ ERROR `&` without an explicit lifetime name cannot be used here
14     fn foo<const M: &u8>(&self) {}
15     //~^ ERROR `&` without an explicit lifetime name cannot be used here
16 }
17
18 impl<const N: &u8> B for A<N> {}
19 //~^ ERROR `&` without an explicit lifetime name cannot be used here
20
21 fn bar<const N: &u8>() {}
22 //~^ ERROR `&` without an explicit lifetime name cannot be used here
23
24 fn main() {}