]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const-arg-in-const-arg.rs
Merge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyup
[rust.git] / src / test / ui / const-generics / const-arg-in-const-arg.rs
1 // revisions: min
2 // FIXME(const_generics): This test currently causes an ICE because
3 // we don't yet correctly deal with lifetimes, reenable this test once
4 // this is fixed.
5
6 const fn foo<T>() -> usize { std::mem::size_of::<T>() }
7 const fn bar<const N: usize>() -> usize { N }
8 const fn faz<'a>(_: &'a ()) -> usize { 13 }
9 const fn baz<'a>(_: &'a ()) -> usize where &'a (): Sized { 13 }
10
11 struct Foo<const N: usize>;
12 fn test<'a, 'b, T, const N: usize>() where &'b (): Sized {
13     let _: [u8; foo::<T>()]; //~ ERROR generic parameters may not
14     let _: [u8; bar::<N>()]; //~ ERROR generic parameters may not
15     let _: [u8; faz::<'a>(&())]; //~ ERROR a non-static lifetime
16     let _: [u8; baz::<'a>(&())]; //~ ERROR a non-static lifetime
17     let _: [u8; faz::<'b>(&())]; //~ ERROR a non-static lifetime
18     let _: [u8; baz::<'b>(&())]; //~ ERROR a non-static lifetime
19
20     // NOTE: This can be a future compat warning instead of an error,
21     // so we stop compilation before emitting this error in this test.
22     let _ = [0; foo::<T>()];
23
24     let _ = [0; bar::<N>()]; //~ ERROR generic parameters may not
25     let _ = [0; faz::<'a>(&())]; //~ ERROR a non-static lifetime
26     let _ = [0; baz::<'a>(&())]; //~ ERROR a non-static lifetime
27     let _ = [0; faz::<'b>(&())]; //~ ERROR a non-static lifetime
28     let _ = [0; baz::<'b>(&())]; //~ ERROR a non-static lifetime
29     let _: Foo<{ foo::<T>() }>; //~ ERROR generic parameters may not
30     let _: Foo<{ bar::<N>() }>; //~ ERROR generic parameters may not
31     let _: Foo<{ faz::<'a>(&()) }>; //~ ERROR a non-static lifetime
32     let _: Foo<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime
33     let _: Foo<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime
34     let _: Foo<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime
35     let _ = Foo::<{ foo::<T>() }>; //~ ERROR generic parameters may not
36     let _ = Foo::<{ bar::<N>() }>; //~ ERROR generic parameters may not
37     let _ = Foo::<{ faz::<'a>(&()) }>; //~ ERROR a non-static lifetime
38     let _ = Foo::<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime
39     let _ = Foo::<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime
40     let _ = Foo::<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime
41 }
42
43 fn main() {}