File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -755,8 +755,8 @@ fn check_attr_whitelist(attrs: &[Attribute], caller: WhiteListCaller) -> Result<
755
755
] ;
756
756
757
757
' o: for attr in attrs {
758
- for val in whitelist {
759
- if eq ( attr , val ) {
758
+ if let Some ( attr_name ) = get_attr_name ( attr ) {
759
+ if whitelist . contains ( & attr_name . as_str ( ) ) {
760
760
continue ' o;
761
761
}
762
762
}
@@ -786,3 +786,24 @@ fn check_attr_whitelist(attrs: &[Attribute], caller: WhiteListCaller) -> Result<
786
786
fn eq ( attr : & Attribute , name : & str ) -> bool {
787
787
attr. style == AttrStyle :: Outer && attr. path ( ) . is_ident ( name)
788
788
}
789
+
790
+ fn get_attr_name ( attr : & Attribute ) -> Option < String > {
791
+ if !matches ! ( attr. style, AttrStyle :: Outer ) {
792
+ return None ;
793
+ }
794
+
795
+ let name = attr. path ( ) . get_ident ( ) . map ( |x| x. to_string ( ) ) ;
796
+
797
+ // In Rust 2024 edition, link_section attribute must be marked as unsafe.
798
+ // So, in the case, check the inner content of `#[unsafe(...)]`.
799
+ match & name {
800
+ Some ( name) if name == "unsafe" => {
801
+ if let Ok ( inner_meta) = attr. parse_args :: < syn:: Meta > ( ) {
802
+ inner_meta. path ( ) . get_ident ( ) . map ( |x| x. to_string ( ) )
803
+ } else {
804
+ None
805
+ }
806
+ }
807
+ _ => name,
808
+ }
809
+ }
You can’t perform that action at this time.
0 commit comments