]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const-arg-in-const-arg.rs
Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk
[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 #![cfg_attr(min, feature(min_const_generics))]
6
7 const fn foo<T>() -> usize { std::mem::size_of::<T>() }
8 const fn bar<const N: usize>() -> usize { N }
9 const fn faz<'a>(_: &'a ()) -> usize { 13 }
10 const fn baz<'a>(_: &'a ()) -> usize where &'a (): Sized { 13 }
11
12 struct Foo<const N: usize>;
13 fn test<'a, 'b, T, const N: usize>() where &'b (): Sized {
14     let _: [u8; foo::<T>()]; //~ ERROR generic parameters may not
15     let _: [u8; bar::<N>()]; //~ ERROR generic parameters may not
16     let _: [u8; faz::<'a>(&())]; //~ ERROR a non-static lifetime
17     let _: [u8; baz::<'a>(&())]; //~ ERROR a non-static lifetime
18     let _: [u8; faz::<'b>(&())]; //~ ERROR a non-static lifetime
19     let _: [u8; baz::<'b>(&())]; //~ ERROR a non-static lifetime
20
21     // NOTE: This can be a future compat warning instead of an error,
22     // so we stop compilation before emitting this error in this test.
23     let _ = [0; foo::<T>()];
24
25     let _ = [0; bar::<N>()]; //~ ERROR generic parameters may not
26     let _ = [0; faz::<'a>(&())]; //~ ERROR a non-static lifetime
27     let _ = [0; baz::<'a>(&())]; //~ ERROR a non-static lifetime
28     let _ = [0; faz::<'b>(&())]; //~ ERROR a non-static lifetime
29     let _ = [0; baz::<'b>(&())]; //~ ERROR a non-static lifetime
30     let _: Foo<{ foo::<T>() }>; //~ ERROR generic parameters may not
31     let _: Foo<{ bar::<N>() }>; //~ ERROR generic parameters may not
32     let _: Foo<{ faz::<'a>(&()) }>; //~ ERROR a non-static lifetime
33     let _: Foo<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime
34     let _: Foo<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime
35     let _: Foo<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime
36     let _ = Foo::<{ foo::<T>() }>; //~ ERROR generic parameters may not
37     let _ = Foo::<{ bar::<N>() }>; //~ ERROR generic parameters may not
38     let _ = Foo::<{ faz::<'a>(&()) }>; //~ ERROR a non-static lifetime
39     let _ = Foo::<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime
40     let _ = Foo::<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime
41     let _ = Foo::<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime
42 }
43
44 fn main() {}