File tree 4 files changed +33
-3
lines changed
compiler/rustc_passes/src
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> {
680
680
}
681
681
682
682
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
+
683
687
self . dcx ( ) . emit_err ( errors:: NakedFunctionIncompatibleAttribute {
684
688
span : other_attr. span ( ) ,
685
689
naked_span : attr. span ( ) ,
686
- attr : other_attr . name ( ) . unwrap ( ) ,
690
+ attr : other_attr_name ,
687
691
} ) ;
688
692
689
693
return ;
Original file line number Diff line number Diff line change @@ -1249,7 +1249,7 @@ pub(crate) struct NakedFunctionIncompatibleAttribute {
1249
1249
pub span : Span ,
1250
1250
#[ label( passes_naked_attribute) ]
1251
1251
pub naked_span : Span ,
1252
- pub attr : Symbol ,
1252
+ pub attr : String ,
1253
1253
}
1254
1254
1255
1255
#[ derive( Diagnostic ) ]
Original file line number Diff line number Diff line change @@ -51,3 +51,12 @@ fn main() {
51
51
#[ unsafe( naked) ] //~ ERROR should be applied to a function definition
52
52
|| { } ;
53
53
}
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
+
1
7
error: attribute should be applied to a function definition
2
8
--> $DIR/naked-invalid-attr.rs:13:1
3
9
|
@@ -27,6 +33,15 @@ LL | #[unsafe(naked)]
27
33
LL | || {};
28
34
| ----- not a function definition
29
35
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
+
30
45
error: attribute should be applied to a function definition
31
46
--> $DIR/naked-invalid-attr.rs:22:5
32
47
|
@@ -49,5 +64,7 @@ error: attribute should be applied to a function definition
49
64
LL | #![unsafe(naked)]
50
65
| ^^^^^^^^^^^^^^^^^ cannot be applied to crates
51
66
52
- error: aborting due to 6 previous errors
67
+ error: aborting due to 8 previous errors
53
68
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