@@ -44,16 +44,16 @@ impl MarkedAttrs {
4444impl NestedMetaItem {
4545 /// Returns the `MetaItem` if `self` is a `NestedMetaItem::MetaItem`.
4646 pub fn meta_item ( & self ) -> Option < & MetaItem > {
47- match * self {
48- NestedMetaItem :: MetaItem ( ref item) => Some ( item) ,
47+ match self {
48+ NestedMetaItem :: MetaItem ( item) => Some ( item) ,
4949 _ => None ,
5050 }
5151 }
5252
5353 /// Returns the `Lit` if `self` is a `NestedMetaItem::Literal`s.
5454 pub fn literal ( & self ) -> Option < & Lit > {
55- match * self {
56- NestedMetaItem :: Literal ( ref lit) => Some ( lit) ,
55+ match self {
56+ NestedMetaItem :: Literal ( lit) => Some ( lit) ,
5757 _ => None ,
5858 }
5959 }
@@ -116,18 +116,18 @@ impl NestedMetaItem {
116116impl Attribute {
117117 #[ inline]
118118 pub fn has_name ( & self , name : Symbol ) -> bool {
119- match self . kind {
120- AttrKind :: Normal ( ref normal) => normal. item . path == name,
119+ match & self . kind {
120+ AttrKind :: Normal ( normal) => normal. item . path == name,
121121 AttrKind :: DocComment ( ..) => false ,
122122 }
123123 }
124124
125125 /// For a single-segment attribute, returns its name; otherwise, returns `None`.
126126 pub fn ident ( & self ) -> Option < Ident > {
127- match self . kind {
128- AttrKind :: Normal ( ref normal) => {
129- if normal. item . path . segments . len ( ) == 1 {
130- Some ( normal . item . path . segments [ 0 ] . ident )
127+ match & self . kind {
128+ AttrKind :: Normal ( normal) => {
129+ if let [ ident ] = & * normal. item . path . segments {
130+ Some ( ident . ident )
131131 } else {
132132 None
133133 }
@@ -140,17 +140,15 @@ impl Attribute {
140140 }
141141
142142 pub fn value_str ( & self ) -> Option < Symbol > {
143- match self . kind {
144- AttrKind :: Normal ( ref normal) => {
145- normal. item . meta_kind ( ) . and_then ( |kind| kind. value_str ( ) )
146- }
143+ match & self . kind {
144+ AttrKind :: Normal ( normal) => normal. item . meta_kind ( ) . and_then ( |kind| kind. value_str ( ) ) ,
147145 AttrKind :: DocComment ( ..) => None ,
148146 }
149147 }
150148
151149 pub fn meta_item_list ( & self ) -> Option < Vec < NestedMetaItem > > {
152- match self . kind {
153- AttrKind :: Normal ( ref normal) => match normal. item . meta_kind ( ) {
150+ match & self . kind {
151+ AttrKind :: Normal ( normal) => match normal. item . meta_kind ( ) {
154152 Some ( MetaItemKind :: List ( list) ) => Some ( list) ,
155153 _ => None ,
156154 } ,
@@ -191,8 +189,8 @@ impl MetaItem {
191189 }
192190
193191 pub fn meta_item_list ( & self ) -> Option < & [ NestedMetaItem ] > {
194- match self . kind {
195- MetaItemKind :: List ( ref l) => Some ( & l [ .. ] ) ,
192+ match & self . kind {
193+ MetaItemKind :: List ( l) => Some ( & * * l ) ,
196194 _ => None ,
197195 }
198196 }
@@ -268,9 +266,9 @@ impl Attribute {
268266 /// * `#[doc = "doc"]` returns `Some("doc")`.
269267 /// * `#[doc(...)]` returns `None`.
270268 pub fn doc_str ( & self ) -> Option < Symbol > {
271- match self . kind {
272- AttrKind :: DocComment ( .., data) => Some ( data) ,
273- AttrKind :: Normal ( ref normal) if normal. item . path == sym:: doc => {
269+ match & self . kind {
270+ AttrKind :: DocComment ( .., data) => Some ( * data) ,
271+ AttrKind :: Normal ( normal) if normal. item . path == sym:: doc => {
274272 normal. item . meta_kind ( ) . and_then ( |kind| kind. value_str ( ) )
275273 }
276274 _ => None ,
@@ -282,8 +280,8 @@ impl Attribute {
282280 }
283281
284282 pub fn get_normal_item ( & self ) -> & AttrItem {
285- match self . kind {
286- AttrKind :: Normal ( ref normal) => & normal. item ,
283+ match & self . kind {
284+ AttrKind :: Normal ( normal) => & normal. item ,
287285 AttrKind :: DocComment ( ..) => panic ! ( "unexpected doc comment" ) ,
288286 }
289287 }
@@ -297,28 +295,28 @@ impl Attribute {
297295
298296 /// Extracts the MetaItem from inside this Attribute.
299297 pub fn meta ( & self ) -> Option < MetaItem > {
300- match self . kind {
301- AttrKind :: Normal ( ref normal) => normal. item . meta ( self . span ) ,
298+ match & self . kind {
299+ AttrKind :: Normal ( normal) => normal. item . meta ( self . span ) ,
302300 AttrKind :: DocComment ( ..) => None ,
303301 }
304302 }
305303
306304 pub fn meta_kind ( & self ) -> Option < MetaItemKind > {
307- match self . kind {
308- AttrKind :: Normal ( ref normal) => normal. item . meta_kind ( ) ,
305+ match & self . kind {
306+ AttrKind :: Normal ( normal) => normal. item . meta_kind ( ) ,
309307 AttrKind :: DocComment ( ..) => None ,
310308 }
311309 }
312310
313311 pub fn tokens ( & self ) -> TokenStream {
314- match self . kind {
315- AttrKind :: Normal ( ref normal) => normal
312+ match & self . kind {
313+ AttrKind :: Normal ( normal) => normal
316314 . tokens
317315 . as_ref ( )
318316 . unwrap_or_else ( || panic ! ( "attribute is missing tokens: {:?}" , self ) )
319317 . to_attr_token_stream ( )
320318 . to_tokenstream ( ) ,
321- AttrKind :: DocComment ( comment_kind, data) => TokenStream :: new ( vec ! [ TokenTree :: Token (
319+ & AttrKind :: DocComment ( comment_kind, data) => TokenStream :: new ( vec ! [ TokenTree :: Token (
322320 Token :: new( token:: DocComment ( comment_kind, self . style, data) , self . span) ,
323321 Spacing :: Alone ,
324322 ) ] ) ,
@@ -496,17 +494,17 @@ impl MetaItem {
496494 let span = span. with_hi ( segments. last ( ) . unwrap ( ) . ident . span . hi ( ) ) ;
497495 Path { span, segments, tokens : None }
498496 }
499- Some ( TokenTree :: Token ( Token { kind : token:: Interpolated ( nt) , .. } , _) ) => match * nt {
500- token:: Nonterminal :: NtMeta ( ref item) => return item. meta ( item. path . span ) ,
501- token:: Nonterminal :: NtPath ( ref path) => ( * * path) . clone ( ) ,
497+ Some ( TokenTree :: Token ( Token { kind : token:: Interpolated ( nt) , .. } , _) ) => match & * nt {
498+ token:: Nonterminal :: NtMeta ( item) => return item. meta ( item. path . span ) ,
499+ token:: Nonterminal :: NtPath ( path) => ( * * path) . clone ( ) ,
502500 _ => return None ,
503501 } ,
504502 _ => return None ,
505503 } ;
506504 let list_closing_paren_pos = tokens. peek ( ) . map ( |tt| tt. span ( ) . hi ( ) ) ;
507505 let kind = MetaItemKind :: from_tokens ( tokens) ?;
508- let hi = match kind {
509- MetaItemKind :: NameValue ( ref lit) => lit. span . hi ( ) ,
506+ let hi = match & kind {
507+ MetaItemKind :: NameValue ( lit) => lit. span . hi ( ) ,
510508 MetaItemKind :: List ( ..) => list_closing_paren_pos. unwrap_or ( path. span . hi ( ) ) ,
511509 _ => path. span . hi ( ) ,
512510 } ;
@@ -518,8 +516,8 @@ impl MetaItem {
518516impl MetaItemKind {
519517 pub fn value_str ( & self ) -> Option < Symbol > {
520518 match self {
521- MetaItemKind :: NameValue ( ref v) => match v. kind {
522- LitKind :: Str ( ref s, _) => Some ( * s) ,
519+ MetaItemKind :: NameValue ( v) => match v. kind {
520+ LitKind :: Str ( s, _) => Some ( s) ,
523521 _ => None ,
524522 } ,
525523 _ => None ,
@@ -557,15 +555,15 @@ impl MetaItemKind {
557555 }
558556
559557 fn token_trees ( & self , span : Span ) -> Vec < TokenTree > {
560- match * self {
558+ match self {
561559 MetaItemKind :: Word => vec ! [ ] ,
562- MetaItemKind :: NameValue ( ref lit) => {
560+ MetaItemKind :: NameValue ( lit) => {
563561 vec ! [
564562 TokenTree :: token_alone( token:: Eq , span) ,
565563 TokenTree :: Token ( lit. to_token( ) , Spacing :: Alone ) ,
566564 ]
567565 }
568- MetaItemKind :: List ( ref list) => {
566+ MetaItemKind :: List ( list) => {
569567 let mut tokens = Vec :: new ( ) ;
570568 for ( i, item) in list. iter ( ) . enumerate ( ) {
571569 if i > 0 {
@@ -648,16 +646,16 @@ impl MetaItemKind {
648646
649647impl NestedMetaItem {
650648 pub fn span ( & self ) -> Span {
651- match * self {
652- NestedMetaItem :: MetaItem ( ref item) => item. span ,
653- NestedMetaItem :: Literal ( ref lit) => lit. span ,
649+ match self {
650+ NestedMetaItem :: MetaItem ( item) => item. span ,
651+ NestedMetaItem :: Literal ( lit) => lit. span ,
654652 }
655653 }
656654
657655 fn token_trees ( & self ) -> Vec < TokenTree > {
658- match * self {
659- NestedMetaItem :: MetaItem ( ref item) => item. token_trees ( ) ,
660- NestedMetaItem :: Literal ( ref lit) => {
656+ match self {
657+ NestedMetaItem :: MetaItem ( item) => item. token_trees ( ) ,
658+ NestedMetaItem :: Literal ( lit) => {
661659 vec ! [ TokenTree :: Token ( lit. to_token( ) , Spacing :: Alone ) ]
662660 }
663661 }
0 commit comments