@@ -88,6 +88,7 @@ use smallvec::{smallvec, SmallVec};
88
88
use syntax_pos:: Span ;
89
89
90
90
use rustc_data_structures:: fx:: FxHashMap ;
91
+ use rustc_data_structures:: sync:: Lrc ;
91
92
use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
92
93
use std:: mem;
93
94
use std:: ops:: { Deref , DerefMut } ;
@@ -179,7 +180,7 @@ struct MatcherPos<'root, 'tt: 'root> {
179
180
/// all bound matches from the submatcher into the shared top-level `matches` vector. If `sep`
180
181
/// and `up` are `Some`, then `matches` is _not_ the shared top-level list. Instead, if one
181
182
/// wants the shared `matches`, one should use `up.matches`.
182
- matches : Box < [ Rc < NamedMatchVec > ] > ,
183
+ matches : Box < [ Lrc < NamedMatchVec > ] > ,
183
184
/// The position in `matches` corresponding to the first metavar in this matcher's sequence of
184
185
/// token trees. In other words, the first metavar in the first token of `top_elts` corresponds
185
186
/// to `matches[match_lo]`.
@@ -218,7 +219,7 @@ struct MatcherPos<'root, 'tt: 'root> {
218
219
impl < ' root , ' tt > MatcherPos < ' root , ' tt > {
219
220
/// Adds `m` as a named match for the `idx`-th metavar.
220
221
fn push_match ( & mut self , idx : usize , m : NamedMatch ) {
221
- let matches = Rc :: make_mut ( & mut self . matches [ idx] ) ;
222
+ let matches = Lrc :: make_mut ( & mut self . matches [ idx] ) ;
222
223
matches. push ( m) ;
223
224
}
224
225
}
@@ -295,11 +296,11 @@ pub fn count_names(ms: &[TokenTree]) -> usize {
295
296
}
296
297
297
298
/// `len` `Vec`s (initially shared and empty) that will store matches of metavars.
298
- fn create_matches ( len : usize ) -> Box < [ Rc < NamedMatchVec > ] > {
299
+ fn create_matches ( len : usize ) -> Box < [ Lrc < NamedMatchVec > ] > {
299
300
if len == 0 {
300
301
vec ! [ ]
301
302
} else {
302
- let empty_matches = Rc :: new ( SmallVec :: new ( ) ) ;
303
+ let empty_matches = Lrc :: new ( SmallVec :: new ( ) ) ;
303
304
vec ! [ empty_matches; len]
304
305
} . into_boxed_slice ( )
305
306
}
@@ -353,8 +354,8 @@ fn initial_matcher_pos<'root, 'tt>(ms: &'tt [TokenTree], open: Span) -> MatcherP
353
354
/// token tree it was derived from.
354
355
#[ derive( Debug , Clone ) ]
355
356
pub enum NamedMatch {
356
- MatchedSeq ( Rc < NamedMatchVec > , DelimSpan ) ,
357
- MatchedNonterminal ( Rc < Nonterminal > ) ,
357
+ MatchedSeq ( Lrc < NamedMatchVec > , DelimSpan ) ,
358
+ MatchedNonterminal ( Lrc < Nonterminal > ) ,
358
359
}
359
360
360
361
/// Takes a sequence of token trees `ms` representing a matcher which successfully matched input
@@ -561,7 +562,7 @@ fn inner_parse_loop<'root, 'tt>(
561
562
new_item. match_cur += seq. num_captures ;
562
563
new_item. idx += 1 ;
563
564
for idx in item. match_cur ..item. match_cur + seq. num_captures {
564
- new_item. push_match ( idx, MatchedSeq ( Rc :: new ( smallvec ! [ ] ) , sp) ) ;
565
+ new_item. push_match ( idx, MatchedSeq ( Lrc :: new ( smallvec ! [ ] ) , sp) ) ;
565
566
}
566
567
cur_items. push ( new_item) ;
567
568
}
@@ -707,7 +708,7 @@ pub fn parse(
707
708
let matches = eof_items[ 0 ]
708
709
. matches
709
710
. iter_mut ( )
710
- . map ( |dv| Rc :: make_mut ( dv) . pop ( ) . unwrap ( ) ) ;
711
+ . map ( |dv| Lrc :: make_mut ( dv) . pop ( ) . unwrap ( ) ) ;
711
712
return nameize ( sess, ms, matches) ;
712
713
} else if eof_items. len ( ) > 1 {
713
714
return Error (
@@ -780,7 +781,7 @@ pub fn parse(
780
781
let match_cur = item. match_cur ;
781
782
item. push_match (
782
783
match_cur,
783
- MatchedNonterminal ( Rc :: new ( parse_nt ( & mut parser, span, & ident. as_str ( ) ) ) ) ,
784
+ MatchedNonterminal ( Lrc :: new ( parse_nt ( & mut parser, span, & ident. as_str ( ) ) ) ) ,
784
785
) ;
785
786
item. idx += 1 ;
786
787
item. match_cur += 1 ;
@@ -829,7 +830,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool {
829
830
} ,
830
831
"block" => match * token {
831
832
Token :: OpenDelim ( token:: Brace ) => true ,
832
- Token :: Interpolated ( ref nt) => match nt . 0 {
833
+ Token :: Interpolated ( ref nt) => match * * nt {
833
834
token:: NtItem ( _)
834
835
| token:: NtPat ( _)
835
836
| token:: NtTy ( _)
@@ -843,9 +844,9 @@ fn may_begin_with(name: &str, token: &Token) -> bool {
843
844
} ,
844
845
"path" | "meta" => match * token {
845
846
Token :: ModSep | Token :: Ident ( ..) => true ,
846
- Token :: Interpolated ( ref nt) => match nt . 0 {
847
+ Token :: Interpolated ( ref nt) => match * * nt {
847
848
token:: NtPath ( _) | token:: NtMeta ( _) => true ,
848
- _ => may_be_ident ( & nt. 0 ) ,
849
+ _ => may_be_ident ( & nt) ,
849
850
} ,
850
851
_ => false ,
851
852
} ,
@@ -862,12 +863,12 @@ fn may_begin_with(name: &str, token: &Token) -> bool {
862
863
Token :: ModSep | // path
863
864
Token :: Lt | // path (UFCS constant)
864
865
Token :: BinOp ( token:: Shl ) => true , // path (double UFCS)
865
- Token :: Interpolated ( ref nt) => may_be_ident ( & nt . 0 ) ,
866
+ Token :: Interpolated ( ref nt) => may_be_ident ( nt ) ,
866
867
_ => false ,
867
868
} ,
868
869
"lifetime" => match * token {
869
870
Token :: Lifetime ( _) => true ,
870
- Token :: Interpolated ( ref nt) => match nt . 0 {
871
+ Token :: Interpolated ( ref nt) => match * * nt {
871
872
token:: NtLifetime ( _) | token:: NtTT ( _) => true ,
872
873
_ => false ,
873
874
} ,
0 commit comments