File tree Expand file tree Collapse file tree 4 files changed +125
-84
lines changed
compiler/rustc_attr_parsing/src/attributes Expand file tree Collapse file tree 4 files changed +125
-84
lines changed Original file line number Diff line number Diff line change @@ -467,8 +467,14 @@ impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
467
467
const PATH : & [ Symbol ] = & [ sym:: link_section] ;
468
468
const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepInnermost ;
469
469
const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: WarnButFutureError ;
470
- const ALLOWED_TARGETS : AllowedTargets =
471
- AllowedTargets :: AllowListWarnRest ( & [ Allow ( Target :: Static ) , Allow ( Target :: Fn ) ] ) ;
470
+ const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowListWarnRest ( & [
471
+ Allow ( Target :: Static ) ,
472
+ Allow ( Target :: Fn ) ,
473
+ Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
474
+ Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
475
+ Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
476
+ Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
477
+ ] ) ;
472
478
const TEMPLATE : AttributeTemplate = template ! (
473
479
NameValueStr : "name" ,
474
480
"https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute"
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ LL | #[link_section = "x"]
82
82
| ^^^^^^^^^^^^^^^^^^^^^
83
83
|
84
84
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
85
- = help: `#[link_section]` can be applied to statics and functions
85
+ = help: `#[link_section]` can be applied to functions and statics
86
86
87
87
warning: `#[link_ordinal]` attribute cannot be used on macro calls
88
88
--> $DIR/attr-on-mac-call.rs:33:5
Original file line number Diff line number Diff line change @@ -705,6 +705,32 @@ mod link_section {
705
705
//~| WARN previously accepted
706
706
//~| HELP can be applied to
707
707
//~| HELP remove the attribute
708
+
709
+ #[ link_section = "1800" ]
710
+ //~^ WARN attribute cannot be used on
711
+ //~| WARN previously accepted
712
+ //~| HELP can be applied to
713
+ //~| HELP remove the attribute
714
+ trait Tr {
715
+ #[ link_section = "1800" ]
716
+ fn inside_tr_no_default ( & self ) ;
717
+
718
+ #[ link_section = "1800" ]
719
+ fn inside_tr_default ( & self ) { }
720
+ }
721
+
722
+ impl S {
723
+ #[ link_section = "1800" ]
724
+ fn inside_abc_123 ( & self ) { }
725
+ }
726
+
727
+ impl Tr for S {
728
+ #[ link_section = "1800" ]
729
+ fn inside_tr_no_default ( & self ) { }
730
+ }
731
+
732
+ #[ link_section = "1800" ]
733
+ fn should_always_link ( ) { }
708
734
}
709
735
710
736
You can’t perform that action at this time.
0 commit comments