Skip to content

Commit

Permalink
Merge from rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
The Miri Conjob Bot committed Jul 18, 2023
2 parents 3a2b0aa + ce57230 commit 9a1c5ef
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/fail/function_calls/target_feature.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@only-target-x86_64: uses x86 target features

fn main() {
assert!(!is_x86_feature_detected!("ssse3"));
unsafe {
ssse3_fn(); //~ ERROR: calling a function that requires unavailable target features: ssse3
}
}

#[target_feature(enable = "ssse3")]
unsafe fn ssse3_fn() {}
15 changes: 15 additions & 0 deletions tests/fail/function_calls/target_feature.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: Undefined Behavior: calling a function that requires unavailable target features: ssse3
--> $DIR/target_feature.rs:LL:CC
|
LL | ssse3_fn();
| ^^^^^^^^^^ calling a function that requires unavailable target features: ssse3
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at $DIR/target_feature.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error

12 changes: 12 additions & 0 deletions tests/pass/function_calls/target_feature.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@only-target-x86_64: uses x86 target features
//@compile-flags: -C target-feature=+ssse3

fn main() {
assert!(is_x86_feature_detected!("ssse3"));
unsafe {
ssse3_fn();
}
}

#[target_feature(enable = "ssse3")]
unsafe fn ssse3_fn() {}

0 comments on commit 9a1c5ef

Please sign in to comment.