]> git.lizzy.rs Git - rust.git/blob - src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs
Rollup merge of #105502 - chenyukang:yukang/fix-105366-impl, r=estebank
[rust.git] / src / test / ui / invalid / invalid-rustc_legacy_const_generics-arguments.rs
1 #![feature(rustc_attrs)]
2
3 #[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] must have one index for
4 fn foo1() {}
5
6 #[rustc_legacy_const_generics(1)] //~ ERROR index exceeds number of arguments
7 fn foo2<const X: usize>() {}
8
9 #[rustc_legacy_const_generics(2)] //~ ERROR index exceeds number of arguments
10 fn foo3<const X: usize>(_: u8) {}
11
12 #[rustc_legacy_const_generics(a)] //~ ERROR arguments should be non-negative integers
13 fn foo4<const X: usize>() {}
14
15 #[rustc_legacy_const_generics(1, a, 2, b)] //~ ERROR arguments should be non-negative integers
16 fn foo5<const X: usize, const Y: usize, const Z: usize, const W: usize>() {}
17
18 #[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function
19 struct S;
20
21 #[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes
22 fn foo6<const X: usize>() {}
23
24 extern {
25     #[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function
26     fn foo7<const X: usize>(); //~ ERROR foreign items may not have const parameters
27 }
28
29 #[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have
30 fn foo8<X>() {}
31
32 impl S {
33     #[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function
34     fn foo9<const X: usize>() {}
35 }
36
37 #[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute
38 fn bar1() {}
39
40 #[rustc_legacy_const_generics = 1] //~ ERROR malformed `rustc_legacy_const_generics` attribute
41 fn bar2() {}
42
43 fn main() {}