diff options
| author | Folkert <folkert@folkertdev.nl> | 2024-07-23 16:02:32 +0200 |
|---|---|---|
| committer | Folkert <folkert@folkertdev.nl> | 2024-07-27 12:56:20 +0200 |
| commit | a3bb0104ff929674e9d315d9ebec8324f88f367f (patch) | |
| tree | 20ad0147d069aa7dcdfb77ac183a23894a2ed883 | |
| parent | c6a166bac269eda77b595fdc8ff7290e1372c147 (diff) | |
| download | rust-a3bb0104ff929674e9d315d9ebec8324f88f367f.tar.gz rust-a3bb0104ff929674e9d315d9ebec8324f88f367f.zip | |
allow `#[target_feature]` on `#[naked]` functions
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0736.md | 1 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 2 | ||||
| -rw-r--r-- | tests/ui/asm/naked-functions-target-feature.rs | 13 | ||||
| -rw-r--r-- | tests/ui/asm/naked-functions-target-feature.stderr | 12 | ||||
| -rw-r--r-- | tests/ui/asm/naked-functions.rs | 6 |
5 files changed, 7 insertions, 27 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0736.md b/compiler/rustc_error_codes/src/error_codes/E0736.md index 4660d610744..cb7633b7068 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0736.md +++ b/compiler/rustc_error_codes/src/error_codes/E0736.md @@ -5,7 +5,6 @@ Notable attributes that are incompatible with `#[naked]` are: * `#[inline]` * `#[track_caller]` -* `#[target_feature]` * `#[test]`, `#[ignore]`, `#[should_panic]` Erroneous code example: diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index ba0dbfbac12..879cae7a94c 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -423,7 +423,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // // * `#[inline]` // * `#[track_caller]` - // * `#[target_feature]` // * `#[test]`, `#[ignore]`, `#[should_panic]` // // NOTE: when making changes to this list, check that `error_codes/E0736.md` remains accurate @@ -452,6 +451,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { sym::instruction_set, // code generation sym::cold, + sym::target_feature, // documentation sym::doc, ]; diff --git a/tests/ui/asm/naked-functions-target-feature.rs b/tests/ui/asm/naked-functions-target-feature.rs deleted file mode 100644 index 264e7e0976b..00000000000 --- a/tests/ui/asm/naked-functions-target-feature.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ only-x86_64 -//@ needs-asm-support -#![feature(naked_functions)] -#![crate_type = "lib"] - -use std::arch::asm; - -#[target_feature(enable = "sse2")] -//~^ ERROR [E0736] -#[naked] -pub unsafe extern "C" fn naked_target_feature() { - asm!("", options(noreturn)); -} diff --git a/tests/ui/asm/naked-functions-target-feature.stderr b/tests/ui/asm/naked-functions-target-feature.stderr deleted file mode 100644 index f215f99ab79..00000000000 --- a/tests/ui/asm/naked-functions-target-feature.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0736]: attribute incompatible with `#[naked]` - --> $DIR/naked-functions-target-feature.rs:8:1 - | -LL | #[target_feature(enable = "sse2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `target_feature` attribute is incompatible with `#[naked]` -LL | -LL | #[naked] - | -------- function marked with `#[naked]` here - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0736`. diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs index 23d5789ea8c..33cdbd1adb6 100644 --- a/tests/ui/asm/naked-functions.rs +++ b/tests/ui/asm/naked-functions.rs @@ -231,6 +231,12 @@ pub unsafe extern "C" fn compatible_codegen_attributes() { asm!("", options(noreturn, att_syntax)); } +#[target_feature(enable = "sse2")] +#[naked] +pub unsafe extern "C" fn compatible_target_feature() { + asm!("", options(noreturn)); +} + #[doc = "foo bar baz"] #[naked] pub unsafe extern "C" fn compatible_doc_attributes() { |
