File tree Expand file tree Collapse file tree 4 files changed +33
-3
lines changed
compiler/rustc_passes/src Expand file tree Collapse file tree 4 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -680,10 +680,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
680680 }
681681
682682 if !other_attr. has_any_name ( ALLOW_LIST ) {
683+ let path = other_attr. path ( ) ;
684+ let path: Vec < _ > = path. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ;
685+ let other_attr_name = path. join ( "::" ) ;
686+
683687 self . dcx ( ) . emit_err ( errors:: NakedFunctionIncompatibleAttribute {
684688 span : other_attr. span ( ) ,
685689 naked_span : attr. span ( ) ,
686- attr : other_attr . name ( ) . unwrap ( ) ,
690+ attr : other_attr_name ,
687691 } ) ;
688692
689693 return ;
Original file line number Diff line number Diff line change @@ -1249,7 +1249,7 @@ pub(crate) struct NakedFunctionIncompatibleAttribute {
12491249 pub span : Span ,
12501250 #[ label( passes_naked_attribute) ]
12511251 pub naked_span : Span ,
1252- pub attr : Symbol ,
1252+ pub attr : String ,
12531253}
12541254
12551255#[ derive( Diagnostic ) ]
Original file line number Diff line number Diff line change @@ -51,3 +51,12 @@ fn main() {
5151 #[ unsafe( naked) ] //~ ERROR should be applied to a function definition
5252 || { } ;
5353}
54+
55+ // Check that the path of an attribute without a name is printed correctly (issue #140082)
56+ #[ :: a]
57+ //~^ ERROR attribute incompatible with `#[unsafe(naked)]`
58+ //~| ERROR failed to resolve: use of unresolved module or unlinked crate `a`
59+ #[ unsafe( naked) ]
60+ extern "C" fn issue_140082 ( ) {
61+ naked_asm ! ( "" )
62+ }
Original file line number Diff line number Diff line change 1+ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a`
2+ --> $DIR/naked-invalid-attr.rs:56:5
3+ |
4+ LL | #[::a]
5+ | ^ use of unresolved module or unlinked crate `a`
6+
17error: attribute should be applied to a function definition
28 --> $DIR/naked-invalid-attr.rs:13:1
39 |
@@ -27,6 +33,15 @@ LL | #[unsafe(naked)]
2733LL | || {};
2834 | ----- not a function definition
2935
36+ error[E0736]: attribute incompatible with `#[unsafe(naked)]`
37+ --> $DIR/naked-invalid-attr.rs:56:1
38+ |
39+ LL | #[::a]
40+ | ^^^^^^ the `{{root}}::a` attribute is incompatible with `#[unsafe(naked)]`
41+ ...
42+ LL | #[unsafe(naked)]
43+ | ---------------- function marked with `#[unsafe(naked)]` here
44+
3045error: attribute should be applied to a function definition
3146 --> $DIR/naked-invalid-attr.rs:22:5
3247 |
@@ -49,5 +64,7 @@ error: attribute should be applied to a function definition
4964LL | #![unsafe(naked)]
5065 | ^^^^^^^^^^^^^^^^^ cannot be applied to crates
5166
52- error: aborting due to 6 previous errors
67+ error: aborting due to 8 previous errors
5368
69+ Some errors have detailed explanations: E0433, E0736.
70+ For more information about an error, try `rustc --explain E0433`.
You can’t perform that action at this time.
0 commit comments