-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #115910 - eduardosm:lang-fns-target-features, r=cjgillot
Prevent using `#[target_feature]` on lang item functions Fixes #109411 and also prevents from using `#[target_feature]` on other `fn` lang items to mitigate the concerns from #109411 (comment).
- Loading branch information
Showing
7 changed files
with
99 additions
and
3 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
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
19 changes: 19 additions & 0 deletions
19
tests/ui/lang-items/start_lang_item_with_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// only-x86_64 | ||
// check-fail | ||
|
||
#![feature(lang_items, no_core, target_feature_11)] | ||
#![no_core] | ||
|
||
#[lang = "copy"] | ||
pub trait Copy {} | ||
#[lang = "sized"] | ||
pub trait Sized {} | ||
|
||
#[lang = "start"] | ||
#[target_feature(enable = "avx2")] | ||
//~^ ERROR `start` language item function is not allowed to have `#[target_feature]` | ||
fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize { | ||
0 | ||
} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui/lang-items/start_lang_item_with_target_feature.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,11 @@ | ||
error: `start` language item function is not allowed to have `#[target_feature]` | ||
--> $DIR/start_lang_item_with_target_feature.rs:13:1 | ||
| | ||
LL | #[target_feature(enable = "avx2")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | | ||
LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize { | ||
| ------------------------------------------------------------------------------------------- `start` language item function is not allowed to have `#[target_feature]` | ||
|
||
error: aborting due to previous error | ||
|
15 changes: 15 additions & 0 deletions
15
tests/ui/panic-handler/panic-handler-with-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// compile-flags:-C panic=abort | ||
// only-x86_64 | ||
|
||
#![feature(target_feature_11)] | ||
#![no_std] | ||
#![no_main] | ||
|
||
use core::panic::PanicInfo; | ||
|
||
#[panic_handler] | ||
#[target_feature(enable = "avx2")] | ||
//~^ ERROR `panic_impl` language item function is not allowed to have `#[target_feature]` | ||
fn panic(info: &PanicInfo) -> ! { | ||
unimplemented!(); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui/panic-handler/panic-handler-with-target-feature.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,11 @@ | ||
error: `panic_impl` language item function is not allowed to have `#[target_feature]` | ||
--> $DIR/panic-handler-with-target-feature.rs:11:1 | ||
| | ||
LL | #[target_feature(enable = "avx2")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | | ||
LL | fn panic(info: &PanicInfo) -> ! { | ||
| ------------------------------- `panic_impl` language item function is not allowed to have `#[target_feature]` | ||
|
||
error: aborting due to previous error | ||
|