-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for calls to functions with
#[target_feature]
in THIR unsafeck
- Loading branch information
1 parent
27fe959
commit d7787bb
Showing
9 changed files
with
147 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/test/ui/rfcs/rfc-2396-target_feature-11/closures-inherit-target_feature.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../rfc-2396-target_feature-11/fn-ptr.stderr → ...-2396-target_feature-11/fn-ptr.mir.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// revisions: mir thir | ||
// [thir]compile-flags: -Z thir-unsafeck | ||
// only-x86_64 | ||
|
||
#![feature(target_feature_11)] | ||
|
18 changes: 18 additions & 0 deletions
18
src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/fn-ptr.rs:11:21 | ||
| | ||
LL | #[target_feature(enable = "sse2")] | ||
| ---------------------------------- `#[target_feature]` added here | ||
... | ||
LL | let foo: fn() = foo; | ||
| ---- ^^^ cannot coerce functions with `#[target_feature]` to safe function pointers | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected fn pointer `fn()` | ||
found fn item `fn() {foo}` | ||
= note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
20 changes: 10 additions & 10 deletions
20
...-2396-target_feature-11/safe-calls.stderr → ...6-target_feature-11/safe-calls.mir.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// revisions: mir thir | ||
// [thir]compile-flags: -Z thir-unsafeck | ||
// only-x86_64 | ||
|
||
#![feature(target_feature_11)] | ||
|
83 changes: 83 additions & 0 deletions
83
src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:23:5 | ||
| | ||
LL | sse2(); | ||
| ^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:24:5 | ||
| | ||
LL | avx_bmi2(); | ||
| ^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:25:5 | ||
| | ||
LL | Quux.avx_bmi2(); | ||
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:30:5 | ||
| | ||
LL | avx_bmi2(); | ||
| ^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:31:5 | ||
| | ||
LL | Quux.avx_bmi2(); | ||
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:36:5 | ||
| | ||
LL | sse2(); | ||
| ^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:37:5 | ||
| | ||
LL | avx_bmi2(); | ||
| ^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:38:5 | ||
| | ||
LL | Quux.avx_bmi2(); | ||
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:44:5 | ||
| | ||
LL | sse2(); | ||
| ^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:47:18 | ||
| | ||
LL | const name: () = sse2(); | ||
| ^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error: aborting due to 10 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0133`. |