This repository was archived by the owner on May 28, 2025. It is now read-only.
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 =
485
485
passes_naked_functions_codegen_attribute =
486
486
cannot use additional code generation attributes with `#[naked]`
487
487
.label = this attribute is incompatible with `#[naked]`
488
- .label2 = function marked with `#[naked]` here
488
+ .naked_attribute = function marked with `#[naked]` here
489
489
490
490
passes_naked_functions_must_use_noreturn =
491
491
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> {
421
421
const FORBIDDEN : [ rustc_span:: Symbol ; 3 ] =
422
422
[ sym:: track_caller, sym:: inline, sym:: target_feature] ;
423
423
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
-
435
424
match target {
436
425
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
+ }
438
440
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
439
441
// `#[naked]` attribute with just a lint, because we previously
440
442
// 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 {
1188
1188
#[ primary_span]
1189
1189
#[ label]
1190
1190
pub span : Span ,
1191
- #[ label( passes_label2 ) ]
1191
+ #[ label( passes_naked_attribute ) ]
1192
1192
pub naked_span : Span ,
1193
1193
}
1194
1194
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 3
3
4
4
use std:: arch:: asm;
5
5
6
- #[ track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
6
+ #[ track_caller] //~ ERROR [E0736]
7
7
//~^ ERROR `#[track_caller]` requires Rust ABI
8
8
#[ naked]
9
9
extern "C" fn f ( ) {
@@ -15,7 +15,7 @@ extern "C" fn f() {
15
15
struct S ;
16
16
17
17
impl S {
18
- #[ track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
18
+ #[ track_caller] //~ ERROR [E0736]
19
19
//~^ ERROR `#[track_caller]` requires Rust ABI
20
20
#[ naked]
21
21
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]`
2
2
--> $DIR/error-with-naked.rs:6:1
3
3
|
4
4
LL | #[track_caller]
5
- | ^^^^^^^^^^^^^^^
5
+ | ^^^^^^^^^^^^^^^ this attribute is incompatible with `#[naked]`
6
+ LL |
7
+ LL | #[naked]
8
+ | -------- function marked with `#[naked]` here
6
9
7
- error[E0736]: cannot use `#[track_caller]` with `#[naked]`
10
+ error[E0736]: cannot use additional code generation attributes with `#[naked]`
8
11
--> $DIR/error-with-naked.rs:18:5
9
12
|
10
13
LL | #[track_caller]
11
- | ^^^^^^^^^^^^^^^
14
+ | ^^^^^^^^^^^^^^^ this attribute is incompatible with `#[naked]`
15
+ LL |
16
+ LL | #[naked]
17
+ | -------- function marked with `#[naked]` here
12
18
13
19
error[E0737]: `#[track_caller]` requires Rust ABI
14
20
--> $DIR/error-with-naked.rs:6:1
You can’t perform that action at this time.
0 commit comments