]> git.lizzy.rs Git - rust.git/blob - src/test/ui/target-feature/invalid-attribute.rs
Tweak move error
[rust.git] / src / test / 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 #![feature(target_feature)]
16 #![warn(unused_attributes)]
17
18 #[target_feature = "+sse2"]
19 //~^ ERROR malformed `target_feature` attribute
20 #[target_feature(enable = "foo")]
21 //~^ ERROR not valid for this target
22 //~| NOTE `foo` is not valid for this target
23 #[target_feature(bar)]
24 //~^ ERROR malformed `target_feature` attribute
25 #[target_feature(disable = "baz")]
26 //~^ ERROR malformed `target_feature` attribute
27 unsafe fn foo() {}
28
29 #[target_feature(enable = "sse2")]
30 //~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
31 //~| NOTE see issue #69098
32 fn bar() {}
33 //~^ NOTE not an `unsafe` function
34
35 #[target_feature(enable = "sse2")]
36 //~^ ERROR attribute should be applied to a function
37 mod another {}
38 //~^ NOTE not a function
39
40 #[target_feature(enable = "sse2")]
41 //~^ ERROR attribute should be applied to a function
42 const FOO: usize = 7;
43 //~^ NOTE not a function
44
45 #[target_feature(enable = "sse2")]
46 //~^ ERROR attribute should be applied to a function
47 struct Foo;
48 //~^ NOTE not a function
49
50 #[target_feature(enable = "sse2")]
51 //~^ ERROR attribute should be applied to a function
52 enum Bar {}
53 //~^ NOTE not a function
54
55 #[target_feature(enable = "sse2")]
56 //~^ ERROR attribute should be applied to a function
57 union Qux {
58 //~^ NOTE not a function
59     f1: u16,
60     f2: u16,
61 }
62
63 #[target_feature(enable = "sse2")]
64 //~^ ERROR attribute should be applied to a function
65 trait Baz {}
66 //~^ NOTE not a function
67
68 #[inline(always)]
69 //~^ ERROR: cannot use `#[inline(always)]`
70 #[target_feature(enable = "sse2")]
71 unsafe fn test() {}
72
73 trait Quux {
74     fn foo();
75 }
76
77 impl Quux for Foo {
78     #[target_feature(enable = "sse2")]
79     //~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
80     //~| NOTE see issue #69098
81     fn foo() {}
82     //~^ NOTE not an `unsafe` function
83 }
84
85 fn main() {
86     #[target_feature(enable = "sse2")]
87     //~^ ERROR attribute should be applied to a function
88     unsafe {
89         foo();
90         bar();
91     }
92     //~^^^^ NOTE not a function
93
94     #[target_feature(enable = "sse2")]
95     //~^ ERROR attribute should be applied to a function
96     || {};
97     //~^ NOTE not a function
98 }