]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs
Merge commit '4236289b75ee55c78538c749512cdbeea5e1c332' into update-rustfmt
[rust.git] / src / test / ui / rfcs / rfc-2396-target_feature-11 / safe-calls.rs
1 // revisions: mir thir
2 // [thir]compile-flags: -Z thir-unsafeck
3 // only-x86_64
4
5 #![feature(target_feature_11)]
6
7 #[target_feature(enable = "sse2")]
8 const fn sse2() {}
9
10 #[target_feature(enable = "avx")]
11 #[target_feature(enable = "bmi2")]
12 fn avx_bmi2() {}
13
14 struct Quux;
15
16 impl Quux {
17     #[target_feature(enable = "avx")]
18     #[target_feature(enable = "bmi2")]
19     fn avx_bmi2(&self) {}
20 }
21
22 fn foo() {
23     sse2();              //~ ERROR call to function with `#[target_feature]` is unsafe
24     avx_bmi2();          //~ ERROR call to function with `#[target_feature]` is unsafe
25     Quux.avx_bmi2();     //~ ERROR call to function with `#[target_feature]` is unsafe
26 }
27
28 #[target_feature(enable = "sse2")]
29 fn bar() {
30     avx_bmi2();          //~ ERROR call to function with `#[target_feature]` is unsafe
31     Quux.avx_bmi2();     //~ ERROR call to function with `#[target_feature]` is unsafe
32 }
33
34 #[target_feature(enable = "avx")]
35 fn baz() {
36     sse2();              //~ ERROR call to function with `#[target_feature]` is unsafe
37     avx_bmi2();          //~ ERROR call to function with `#[target_feature]` is unsafe
38     Quux.avx_bmi2();     //~ ERROR call to function with `#[target_feature]` is unsafe
39 }
40
41 #[target_feature(enable = "avx")]
42 #[target_feature(enable = "bmi2")]
43 fn qux() {
44     sse2();              //~ ERROR call to function with `#[target_feature]` is unsafe
45 }
46
47 const name: () = sse2(); //~ ERROR call to function with `#[target_feature]` is unsafe
48
49 fn main() {}