File tree Expand file tree Collapse file tree 7 files changed +53
-20
lines changed
rfcs/rfc-2091-track-caller Expand file tree Collapse file tree 7 files changed +53
-20
lines changed Original file line number Diff line number Diff line change @@ -485,7 +485,7 @@ passes_naked_functions_asm_options =
485485passes_naked_functions_codegen_attribute =
486486 cannot use additional code generation attributes with `#[naked]`
487487 .label = this attribute is incompatible with `#[naked]`
488- .label2 = function marked with `#[naked]` here
488+ .naked_attribute = function marked with `#[naked]` here
489489
490490passes_naked_functions_must_use_noreturn =
491491 asm in naked functions must use `noreturn` option
Original file line number Diff line number Diff line change @@ -421,20 +421,22 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
421421 const FORBIDDEN : [ rustc_span:: Symbol ; 3 ] =
422422 [ sym:: track_caller, sym:: inline, sym:: target_feature] ;
423423
424- for other_attr in attrs {
425- if FORBIDDEN . into_iter ( ) . any ( |name| other_attr. has_name ( name) ) {
426- self . dcx ( ) . emit_err ( errors:: NakedFunctionCodegenAttribute {
427- span : other_attr. span ,
428- naked_span : attr. span ,
429- } ) ;
430-
431- return false ;
432- }
433- }
434-
435424 match target {
436425 Target :: Fn
437- | Target :: Method ( MethodKind :: Trait { body : true } | MethodKind :: Inherent ) => true ,
426+ | Target :: Method ( MethodKind :: Trait { body : true } | MethodKind :: Inherent ) => {
427+ for other_attr in attrs {
428+ if FORBIDDEN . into_iter ( ) . any ( |name| other_attr. has_name ( name) ) {
429+ self . dcx ( ) . emit_err ( errors:: NakedFunctionCodegenAttribute {
430+ span : other_attr. span ,
431+ naked_span : attr. span ,
432+ } ) ;
433+
434+ return false ;
435+ }
436+ }
437+
438+ true
439+ }
438440 // FIXME(#80564): We permit struct fields, match arms and macro defs to have an
439441 // `#[naked]` attribute with just a lint, because we previously
440442 // erroneously allowed it and some crates used it accidentally, to be compatible
Original file line number Diff line number Diff line change @@ -1188,7 +1188,7 @@ pub struct NakedFunctionCodegenAttribute {
11881188 #[ primary_span]
11891189 #[ label]
11901190 pub span : Span ,
1191- #[ label( passes_label2 ) ]
1191+ #[ label( passes_naked_attribute ) ]
11921192 pub naked_span : Span ,
11931193}
11941194
Original file line number Diff line number Diff line change 1+ //@ only-x86_64
2+ //@ needs-asm-support
3+ #![ feature( naked_functions) ]
4+ #![ crate_type = "lib" ]
5+
6+ use std:: arch:: asm;
7+
8+ #[ target_feature( enable = "sse2" ) ]
9+ //~^ ERROR [E0736]
10+ #[ naked]
11+ pub unsafe extern "C" fn naked_target_feature ( ) {
12+ asm ! ( "" , options( noreturn) ) ;
13+ }
Original file line number Diff line number Diff line change 1+ error[E0736]: cannot use additional code generation attributes with `#[naked]`
2+ --> $DIR/naked-functions-target-feature.rs:8:1
3+ |
4+ LL | #[target_feature(enable = "sse2")]
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this attribute is incompatible with `#[naked]`
6+ LL |
7+ LL | #[naked]
8+ | -------- function marked with `#[naked]` here
9+
10+ error: aborting due to 1 previous error
11+
12+ For more information about this error, try `rustc --explain E0736`.
Original file line number Diff line number Diff line change 33
44use std:: arch:: asm;
55
6- #[ track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
6+ #[ track_caller] //~ ERROR [E0736]
77//~^ ERROR `#[track_caller]` requires Rust ABI
88#[ naked]
99extern "C" fn f ( ) {
@@ -15,7 +15,7 @@ extern "C" fn f() {
1515struct S ;
1616
1717impl S {
18- #[ track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
18+ #[ track_caller] //~ ERROR [E0736]
1919 //~^ ERROR `#[track_caller]` requires Rust ABI
2020 #[ naked]
2121 extern "C" fn g ( ) {
Original file line number Diff line number Diff line change 1- error[E0736]: cannot use `#[track_caller]` with `#[naked]`
1+ error[E0736]: cannot use additional code generation attributes with `#[naked]`
22 --> $DIR/error-with-naked.rs:6:1
33 |
44LL | #[track_caller]
5- | ^^^^^^^^^^^^^^^
5+ | ^^^^^^^^^^^^^^^ this attribute is incompatible with `#[naked]`
6+ LL |
7+ LL | #[naked]
8+ | -------- function marked with `#[naked]` here
69
7- error[E0736]: cannot use `#[track_caller]` with `#[naked]`
10+ error[E0736]: cannot use additional code generation attributes with `#[naked]`
811 --> $DIR/error-with-naked.rs:18:5
912 |
1013LL | #[track_caller]
11- | ^^^^^^^^^^^^^^^
14+ | ^^^^^^^^^^^^^^^ this attribute is incompatible with `#[naked]`
15+ LL |
16+ LL | #[naked]
17+ | -------- function marked with `#[naked]` here
1218
1319error[E0737]: `#[track_caller]` requires Rust ABI
1420 --> $DIR/error-with-naked.rs:6:1
You can’t perform that action at this time.
0 commit comments