]> git.lizzy.rs Git - rust.git/blob - tests/ui/target-feature/invalid-attribute.rs
Rollup merge of #107194 - xfix:remove-slice-internals-dependency-in-rustc-ast, r...
[rust.git] / tests / ui / target-feature / invalid-attribute.rs
1 // ignore-arm
2 // ignore-aarch64
3 // ignore-wasm
4 // ignore-emscripten
5 // ignore-mips
6 // ignore-mips64
7 // ignore-powerpc
8 // ignore-powerpc64
9 // ignore-powerpc64le
10 // ignore-riscv64
11 // ignore-s390x
12 // ignore-sparc
13 // ignore-sparc64
14
15 #![warn(unused_attributes)]
16
17 #[target_feature = "+sse2"]
18 //~^ ERROR malformed `target_feature` attribute
19 #[target_feature(enable = "foo")]
20 //~^ ERROR not valid for this target
21 //~| NOTE `foo` is not valid for this target
22 #[target_feature(bar)]
23 //~^ ERROR malformed `target_feature` attribute
24 #[target_feature(disable = "baz")]
25 //~^ ERROR malformed `target_feature` attribute
26 unsafe fn foo() {}
27
28 #[target_feature(enable = "sse2")]
29 //~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
30 //~| NOTE see issue #69098
31 fn bar() {}
32 //~^ NOTE not an `unsafe` function
33
34 #[target_feature(enable = "sse2")]
35 //~^ ERROR attribute should be applied to a function
36 mod another {}
37 //~^ NOTE not a function
38
39 #[target_feature(enable = "sse2")]
40 //~^ ERROR attribute should be applied to a function
41 const FOO: usize = 7;
42 //~^ NOTE not a function
43
44 #[target_feature(enable = "sse2")]
45 //~^ ERROR attribute should be applied to a function
46 struct Foo;
47 //~^ NOTE not a function
48
49 #[target_feature(enable = "sse2")]
50 //~^ ERROR attribute should be applied to a function
51 enum Bar {}
52 //~^ NOTE not a function
53
54 #[target_feature(enable = "sse2")]
55 //~^ ERROR attribute should be applied to a function
56 union Qux {
57 //~^ NOTE not a function
58     f1: u16,
59     f2: u16,
60 }
61
62 #[target_feature(enable = "sse2")]
63 //~^ ERROR attribute should be applied to a function
64 trait Baz {}
65 //~^ NOTE not a function
66
67 #[inline(always)]
68 //~^ ERROR: cannot use `#[inline(always)]`
69 #[target_feature(enable = "sse2")]
70 unsafe fn test() {}
71
72 trait Quux {
73     fn foo();
74 }
75
76 impl Quux for Foo {
77     #[target_feature(enable = "sse2")]
78     //~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
79     //~| NOTE see issue #69098
80     fn foo() {}
81     //~^ NOTE not an `unsafe` function
82 }
83
84 fn main() {
85     #[target_feature(enable = "sse2")]
86     //~^ ERROR attribute should be applied to a function
87     unsafe {
88         foo();
89         bar();
90     }
91     //~^^^^ NOTE not a function
92
93     #[target_feature(enable = "sse2")]
94     //~^ ERROR attribute should be applied to a function
95     || {};
96     //~^ NOTE not a function
97 }