@@ -11,7 +11,7 @@ use thin_vec::{ThinVec, thin_vec};
11
11
12
12
use crate :: ast:: {
13
13
AttrArgs , AttrArgsEq , AttrId , AttrItem , AttrKind , AttrStyle , AttrVec , Attribute , DUMMY_NODE_ID ,
14
- DelimArgs , Expr , ExprKind , LitKind , MetaItem , MetaItemKind , MetaItemLit , NestedMetaItem ,
14
+ DelimArgs , Expr , ExprKind , LitKind , MetaItem , MetaItemInner , MetaItemKind , MetaItemLit ,
15
15
NormalAttr , Path , PathSegment , Safety ,
16
16
} ;
17
17
use crate :: ptr:: P ;
@@ -136,7 +136,7 @@ impl Attribute {
136
136
}
137
137
}
138
138
139
- pub fn meta_item_list ( & self ) -> Option < ThinVec < NestedMetaItem > > {
139
+ pub fn meta_item_list ( & self ) -> Option < ThinVec < MetaItemInner > > {
140
140
match & self . kind {
141
141
AttrKind :: Normal ( normal) => normal. item . meta_item_list ( ) ,
142
142
AttrKind :: DocComment ( ..) => None ,
@@ -223,7 +223,7 @@ impl AttrItem {
223
223
self . args . span ( ) . map_or ( self . path . span , |args_span| self . path . span . to ( args_span) )
224
224
}
225
225
226
- fn meta_item_list ( & self ) -> Option < ThinVec < NestedMetaItem > > {
226
+ fn meta_item_list ( & self ) -> Option < ThinVec < MetaItemInner > > {
227
227
match & self . args {
228
228
AttrArgs :: Delimited ( args) if args. delim == Delimiter :: Parenthesis => {
229
229
MetaItemKind :: list_from_tokens ( args. tokens . clone ( ) )
@@ -285,7 +285,7 @@ impl MetaItem {
285
285
matches ! ( self . kind, MetaItemKind :: Word )
286
286
}
287
287
288
- pub fn meta_item_list ( & self ) -> Option < & [ NestedMetaItem ] > {
288
+ pub fn meta_item_list ( & self ) -> Option < & [ MetaItemInner ] > {
289
289
match & self . kind {
290
290
MetaItemKind :: List ( l) => Some ( & * * l) ,
291
291
_ => None ,
@@ -393,11 +393,11 @@ impl MetaItem {
393
393
}
394
394
395
395
impl MetaItemKind {
396
- fn list_from_tokens ( tokens : TokenStream ) -> Option < ThinVec < NestedMetaItem > > {
396
+ fn list_from_tokens ( tokens : TokenStream ) -> Option < ThinVec < MetaItemInner > > {
397
397
let mut tokens = tokens. trees ( ) . peekable ( ) ;
398
398
let mut result = ThinVec :: new ( ) ;
399
399
while tokens. peek ( ) . is_some ( ) {
400
- let item = NestedMetaItem :: from_tokens ( & mut tokens) ?;
400
+ let item = MetaItemInner :: from_tokens ( & mut tokens) ?;
401
401
result. push ( item) ;
402
402
match tokens. next ( ) {
403
403
None | Some ( TokenTree :: Token ( Token { kind : token:: Comma , .. } , _) ) => { }
@@ -460,11 +460,11 @@ impl MetaItemKind {
460
460
}
461
461
}
462
462
463
- impl NestedMetaItem {
463
+ impl MetaItemInner {
464
464
pub fn span ( & self ) -> Span {
465
465
match self {
466
- NestedMetaItem :: MetaItem ( item) => item. span ,
467
- NestedMetaItem :: Lit ( lit) => lit. span ,
466
+ MetaItemInner :: MetaItem ( item) => item. span ,
467
+ MetaItemInner :: Lit ( lit) => lit. span ,
468
468
}
469
469
}
470
470
@@ -488,7 +488,7 @@ impl NestedMetaItem {
488
488
}
489
489
490
490
/// Gets a list of inner meta items from a list `MetaItem` type.
491
- pub fn meta_item_list ( & self ) -> Option < & [ NestedMetaItem ] > {
491
+ pub fn meta_item_list ( & self ) -> Option < & [ MetaItemInner ] > {
492
492
self . meta_item ( ) . and_then ( |meta_item| meta_item. meta_item_list ( ) )
493
493
}
494
494
@@ -519,28 +519,28 @@ impl NestedMetaItem {
519
519
self . meta_item ( ) . and_then ( |meta_item| meta_item. value_str ( ) )
520
520
}
521
521
522
- /// Returns the `MetaItemLit` if `self` is a `NestedMetaItem ::Literal`s.
522
+ /// Returns the `MetaItemLit` if `self` is a `MetaItemInner ::Literal`s.
523
523
pub fn lit ( & self ) -> Option < & MetaItemLit > {
524
524
match self {
525
- NestedMetaItem :: Lit ( lit) => Some ( lit) ,
525
+ MetaItemInner :: Lit ( lit) => Some ( lit) ,
526
526
_ => None ,
527
527
}
528
528
}
529
529
530
- /// Returns the `MetaItem` if `self` is a `NestedMetaItem ::MetaItem` or if it's
531
- /// `NestedMetaItem ::Lit(MetaItemLit { kind: LitKind::Bool(_), .. })`.
532
- pub fn meta_item_or_bool ( & self ) -> Option < & NestedMetaItem > {
530
+ /// Returns the `MetaItem` if `self` is a `MetaItemInner ::MetaItem` or if it's
531
+ /// `MetaItemInner ::Lit(MetaItemLit { kind: LitKind::Bool(_), .. })`.
532
+ pub fn meta_item_or_bool ( & self ) -> Option < & MetaItemInner > {
533
533
match self {
534
- NestedMetaItem :: MetaItem ( _item) => Some ( self ) ,
535
- NestedMetaItem :: Lit ( MetaItemLit { kind : LitKind :: Bool ( _) , .. } ) => Some ( self ) ,
534
+ MetaItemInner :: MetaItem ( _item) => Some ( self ) ,
535
+ MetaItemInner :: Lit ( MetaItemLit { kind : LitKind :: Bool ( _) , .. } ) => Some ( self ) ,
536
536
_ => None ,
537
537
}
538
538
}
539
539
540
- /// Returns the `MetaItem` if `self` is a `NestedMetaItem ::MetaItem`.
540
+ /// Returns the `MetaItem` if `self` is a `MetaItemInner ::MetaItem`.
541
541
pub fn meta_item ( & self ) -> Option < & MetaItem > {
542
542
match self {
543
- NestedMetaItem :: MetaItem ( item) => Some ( item) ,
543
+ MetaItemInner :: MetaItem ( item) => Some ( item) ,
544
544
_ => None ,
545
545
}
546
546
}
@@ -550,22 +550,22 @@ impl NestedMetaItem {
550
550
self . meta_item ( ) . is_some ( )
551
551
}
552
552
553
- fn from_tokens < ' a , I > ( tokens : & mut iter:: Peekable < I > ) -> Option < NestedMetaItem >
553
+ fn from_tokens < ' a , I > ( tokens : & mut iter:: Peekable < I > ) -> Option < MetaItemInner >
554
554
where
555
555
I : Iterator < Item = & ' a TokenTree > ,
556
556
{
557
557
match tokens. peek ( ) {
558
558
Some ( TokenTree :: Token ( token, _) ) if let Some ( lit) = MetaItemLit :: from_token ( token) => {
559
559
tokens. next ( ) ;
560
- return Some ( NestedMetaItem :: Lit ( lit) ) ;
560
+ return Some ( MetaItemInner :: Lit ( lit) ) ;
561
561
}
562
562
Some ( TokenTree :: Delimited ( .., Delimiter :: Invisible , inner_tokens) ) => {
563
563
tokens. next ( ) ;
564
- return NestedMetaItem :: from_tokens ( & mut inner_tokens. trees ( ) . peekable ( ) ) ;
564
+ return MetaItemInner :: from_tokens ( & mut inner_tokens. trees ( ) . peekable ( ) ) ;
565
565
}
566
566
_ => { }
567
567
}
568
- MetaItem :: from_tokens ( tokens) . map ( NestedMetaItem :: MetaItem )
568
+ MetaItem :: from_tokens ( tokens) . map ( MetaItemInner :: MetaItem )
569
569
}
570
570
}
571
571
@@ -676,6 +676,6 @@ pub fn contains_name(attrs: &[Attribute], name: Symbol) -> bool {
676
676
find_by_name ( attrs, name) . is_some ( )
677
677
}
678
678
679
- pub fn list_contains_name ( items : & [ NestedMetaItem ] , name : Symbol ) -> bool {
679
+ pub fn list_contains_name ( items : & [ MetaItemInner ] , name : Symbol ) -> bool {
680
680
items. iter ( ) . any ( |item| item. has_name ( name) )
681
681
}
0 commit comments