This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +9
-6
lines changed
compiler/rustc_passes/src Expand file tree Collapse file tree 4 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -561,12 +561,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
561561 allowed_target : Target ,
562562 ) {
563563 if target != allowed_target {
564+ let path = attr. path ( ) ;
565+ let path: Vec < _ > = path. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ;
566+ let attr_name = path. join ( "::" ) ;
564567 self . tcx . emit_node_span_lint (
565568 UNUSED_ATTRIBUTES ,
566569 hir_id,
567570 attr. span ( ) ,
568571 errors:: OnlyHasEffectOn {
569- attr_name : attr . name_or_empty ( ) ,
572+ attr_name,
570573 target_name : allowed_target. name ( ) . replace ( ' ' , "_" ) ,
571574 } ,
572575 ) ;
Original file line number Diff line number Diff line change @@ -1433,7 +1433,7 @@ pub(crate) struct UselessAssignment<'a> {
14331433#[ derive( LintDiagnostic ) ]
14341434#[ diag( passes_only_has_effect_on) ]
14351435pub ( crate ) struct OnlyHasEffectOn {
1436- pub attr_name : Symbol ,
1436+ pub attr_name : String ,
14371437 pub target_name : String ,
14381438}
14391439
Original file line number Diff line number Diff line change 4444struct Foo {
4545 #[ should_panic:: skip]
4646 //~^ ERROR failed to resolve
47- //~| ERROR `#[]` only has an effect on functions
47+ //~| ERROR `#[should_panic::skip ]` only has an effect on functions
4848 pub field : u8 ,
4949
5050 #[ should_panic:: a:: b:: c]
5151 //~^ ERROR failed to resolve
52- //~| ERROR `#[]` only has an effect on functions
52+ //~| ERROR `#[should_panic::a::b::c ]` only has an effect on functions
5353 pub field2 : u8 ,
5454}
5555
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `den
1616LL | #[deny::skip]
1717 | ^^^^ use of unresolved module or unlinked crate `deny`
1818
19- error: `#[]` only has an effect on functions
19+ error: `#[should_panic::skip ]` only has an effect on functions
2020 --> $DIR/check-builtin-attr-ice.rs:45:5
2121 |
2222LL | #[should_panic::skip]
@@ -28,7 +28,7 @@ note: the lint level is defined here
2828LL | #![deny(unused_attributes)]
2929 | ^^^^^^^^^^^^^^^^^
3030
31- error: `#[]` only has an effect on functions
31+ error: `#[should_panic::a::b::c ]` only has an effect on functions
3232 --> $DIR/check-builtin-attr-ice.rs:50:5
3333 |
3434LL | #[should_panic::a::b::c]
You can’t perform that action at this time.
0 commit comments