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 > {
@@ -357,7 +364,8 @@ impl MetaItem {
357
364
_ => path. span . hi ( ) ,
358
365
} ;
359
366
let span = path. span . with_hi ( hi) ;
360
- Some ( MetaItem { path, kind, span } )
367
+ // FIX THIS LATER
368
+ Some ( MetaItem { unsafety : Unsafe :: No , path, kind, span } )
361
369
}
362
370
}
363
371
@@ -547,11 +555,12 @@ pub fn mk_doc_comment(
547
555
pub fn mk_attr (
548
556
g : & AttrIdGenerator ,
549
557
style : AttrStyle ,
558
+ unsafety : Unsafe ,
550
559
path : Path ,
551
560
args : AttrArgs ,
552
561
span : Span ,
553
562
) -> Attribute {
554
- mk_attr_from_item ( g, AttrItem { path, args, tokens : None } , None , style, span)
563
+ mk_attr_from_item ( g, AttrItem { unsafety , path, args, tokens : None } , None , style, span)
555
564
}
556
565
557
566
pub fn mk_attr_from_item (
@@ -569,15 +578,22 @@ pub fn mk_attr_from_item(
569
578
}
570
579
}
571
580
572
- pub fn mk_attr_word ( g : & AttrIdGenerator , style : AttrStyle , name : Symbol , span : Span ) -> Attribute {
581
+ pub fn mk_attr_word (
582
+ g : & AttrIdGenerator ,
583
+ style : AttrStyle ,
584
+ unsafety : Unsafe ,
585
+ name : Symbol ,
586
+ span : Span ,
587
+ ) -> Attribute {
573
588
let path = Path :: from_ident ( Ident :: new ( name, span) ) ;
574
589
let args = AttrArgs :: Empty ;
575
- mk_attr ( g, style, path, args, span)
590
+ mk_attr ( g, style, unsafety , path, args, span)
576
591
}
577
592
578
593
pub fn mk_attr_nested_word (
579
594
g : & AttrIdGenerator ,
580
595
style : AttrStyle ,
596
+ unsafety : Unsafe ,
581
597
outer : Symbol ,
582
598
inner : Symbol ,
583
599
span : Span ,
@@ -593,12 +609,13 @@ pub fn mk_attr_nested_word(
593
609
delim : Delimiter :: Parenthesis ,
594
610
tokens : inner_tokens,
595
611
} ) ;
596
- mk_attr ( g, style, path, attr_args, span)
612
+ mk_attr ( g, style, unsafety , path, attr_args, span)
597
613
}
598
614
599
615
pub fn mk_attr_name_value_str (
600
616
g : & AttrIdGenerator ,
601
617
style : AttrStyle ,
618
+ unsafety : Unsafe ,
602
619
name : Symbol ,
603
620
val : Symbol ,
604
621
span : Span ,
@@ -613,7 +630,7 @@ pub fn mk_attr_name_value_str(
613
630
} ) ;
614
631
let path = Path :: from_ident ( Ident :: new ( name, span) ) ;
615
632
let args = AttrArgs :: Eq ( span, AttrArgsEq :: Ast ( expr) ) ;
616
- mk_attr ( g, style, path, args, span)
633
+ mk_attr ( g, style, unsafety , path, args, span)
617
634
}
618
635
619
636
pub fn filter_by_name ( attrs : & [ Attribute ] , name : Symbol ) -> impl Iterator < Item = & Attribute > {
0 commit comments