about summary refs log tree commit diff
path: root/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.rs
blob: 43a5a2f16aac16687a642721932fe2a35f84de4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//@ only-x86_64

#[target_feature(enable = "avx")]
fn foo_avx() {}

#[target_feature(enable = "sse2")]
fn foo() {}

#[target_feature(enable = "sse2")]
fn bar() {
    let foo: fn() = foo; // this is OK, as we have the necessary target features.
    let foo: fn() = foo_avx; //~ ERROR mismatched types
}

fn main() {
    if std::is_x86_feature_detected!("sse2") {
        unsafe {
            bar();
        }
    }
    let foo: fn() = foo; //~ ERROR mismatched types
}