1
1
//! Functions dealing with attributes and meta items.
2
2
3
- use crate :: ast:: { AttrArgs , AttrArgsEq , AttrId , AttrItem , AttrKind , AttrStyle , AttrVec , Attribute } ;
3
+ use crate :: ast:: {
4
+ AttrArgs , AttrArgsEq , AttrId , AttrItem , AttrKind , AttrStyle , AttrVec , Attribute , Unsafe ,
5
+ } ;
4
6
use crate :: ast:: { DelimArgs , Expr , ExprKind , LitKind , MetaItemLit } ;
5
7
use crate :: ast:: { MetaItem , MetaItemKind , NestedMetaItem , NormalAttr } ;
6
8
use crate :: ast:: { Path , PathSegment , DUMMY_NODE_ID } ;
@@ -227,7 +229,12 @@ impl AttrItem {
227
229
}
228
230
229
231
pub fn meta ( & self , span : Span ) -> Option < MetaItem > {
230
- Some ( MetaItem { path : self . path . clone ( ) , kind : self . meta_kind ( ) ?, span } )
232
+ Some ( MetaItem {
233
+ unsafety : Unsafe :: No ,
234
+ path : self . path . clone ( ) ,
235
+ kind : self . meta_kind ( ) ?,
236
+ span,
237
+ } )
231
238
}
232
239
233
240
pub fn meta_kind ( & self ) -> Option < MetaItemKind > {
@@ -360,7 +367,8 @@ impl MetaItem {
360
367
_ => path. span . hi ( ) ,
361
368
} ;
362
369
let span = path. span . with_hi ( hi) ;
363
- Some ( MetaItem { path, kind, span } )
370
+ // FIX THIS LATER
371
+ Some ( MetaItem { unsafety : Unsafe :: No , path, kind, span } )
364
372
}
365
373
}
366
374
@@ -544,11 +552,12 @@ pub fn mk_doc_comment(
544
552
pub fn mk_attr (
545
553
g : & AttrIdGenerator ,
546
554
style : AttrStyle ,
555
+ unsafety : Unsafe ,
547
556
path : Path ,
548
557
args : AttrArgs ,
549
558
span : Span ,
550
559
) -> Attribute {
551
- mk_attr_from_item ( g, AttrItem { path, args, tokens : None } , None , style, span)
560
+ mk_attr_from_item ( g, AttrItem { unsafety , path, args, tokens : None } , None , style, span)
552
561
}
553
562
554
563
pub fn mk_attr_from_item (
@@ -566,15 +575,22 @@ pub fn mk_attr_from_item(
566
575
}
567
576
}
568
577
569
- pub fn mk_attr_word ( g : & AttrIdGenerator , style : AttrStyle , name : Symbol , span : Span ) -> Attribute {
578
+ pub fn mk_attr_word (
579
+ g : & AttrIdGenerator ,
580
+ style : AttrStyle ,
581
+ unsafety : Unsafe ,
582
+ name : Symbol ,
583
+ span : Span ,
584
+ ) -> Attribute {
570
585
let path = Path :: from_ident ( Ident :: new ( name, span) ) ;
571
586
let args = AttrArgs :: Empty ;
572
- mk_attr ( g, style, path, args, span)
587
+ mk_attr ( g, style, unsafety , path, args, span)
573
588
}
574
589
575
590
pub fn mk_attr_nested_word (
576
591
g : & AttrIdGenerator ,
577
592
style : AttrStyle ,
593
+ unsafety : Unsafe ,
578
594
outer : Symbol ,
579
595
inner : Symbol ,
580
596
span : Span ,
@@ -590,12 +606,13 @@ pub fn mk_attr_nested_word(
590
606
delim : Delimiter :: Parenthesis ,
591
607
tokens : inner_tokens,
592
608
} ) ;
593
- mk_attr ( g, style, path, attr_args, span)
609
+ mk_attr ( g, style, unsafety , path, attr_args, span)
594
610
}
595
611
596
612
pub fn mk_attr_name_value_str (
597
613
g : & AttrIdGenerator ,
598
614
style : AttrStyle ,
615
+ unsafety : Unsafe ,
599
616
name : Symbol ,
600
617
val : Symbol ,
601
618
span : Span ,
@@ -610,7 +627,7 @@ pub fn mk_attr_name_value_str(
610
627
} ) ;
611
628
let path = Path :: from_ident ( Ident :: new ( name, span) ) ;
612
629
let args = AttrArgs :: Eq ( span, AttrArgsEq :: Ast ( expr) ) ;
613
- mk_attr ( g, style, path, args, span)
630
+ mk_attr ( g, style, unsafety , path, args, span)
614
631
}
615
632
616
633
pub fn filter_by_name ( attrs : & [ Attribute ] , name : Symbol ) -> impl Iterator < Item = & Attribute > {
0 commit comments