Skip to content

Commit

Permalink
allow #[target_feature] on #[naked] functions
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Jul 23, 2024
1 parent 0ed639f commit 6f2318c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 27 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_error_codes/src/error_codes/E0736.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Notable attributes that are incompatible with `#[naked]` are:

* `#[inline]`
* `#[track_caller]`
* `#[target_feature]`
* `#[test]`, `#[ignore]`, `#[should_panic]`

Erroneous code example:
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -449,6 +448,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
sym::naked,
// code generation
sym::cold,
sym::target_feature,
// documentation
sym::doc,
];
Expand Down
13 changes: 0 additions & 13 deletions tests/ui/asm/naked-functions-target-feature.rs

This file was deleted.

12 changes: 0 additions & 12 deletions tests/ui/asm/naked-functions-target-feature.stderr

This file was deleted.

6 changes: 6 additions & 0 deletions tests/ui/asm/naked-functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 6f2318c

Please sign in to comment.