@@ -88,6 +88,7 @@ use smallvec::{smallvec, SmallVec};
8888use syntax_pos:: Span ;
8989
9090use rustc_data_structures:: fx:: FxHashMap ;
91+ use rustc_data_structures:: sync:: Lrc ;
9192use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
9293use std:: mem;
9394use std:: ops:: { Deref , DerefMut } ;
@@ -179,7 +180,7 @@ struct MatcherPos<'root, 'tt: 'root> {
179180 /// all bound matches from the submatcher into the shared top-level `matches` vector. If `sep`
180181 /// and `up` are `Some`, then `matches` is _not_ the shared top-level list. Instead, if one
181182 /// wants the shared `matches`, one should use `up.matches`.
182- matches : Box < [ Rc < NamedMatchVec > ] > ,
183+ matches : Box < [ Lrc < NamedMatchVec > ] > ,
183184 /// The position in `matches` corresponding to the first metavar in this matcher's sequence of
184185 /// token trees. In other words, the first metavar in the first token of `top_elts` corresponds
185186 /// to `matches[match_lo]`.
@@ -218,7 +219,7 @@ struct MatcherPos<'root, 'tt: 'root> {
218219impl < ' root , ' tt > MatcherPos < ' root , ' tt > {
219220 /// Adds `m` as a named match for the `idx`-th metavar.
220221 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] ) ;
222223 matches. push ( m) ;
223224 }
224225}
@@ -295,11 +296,11 @@ pub fn count_names(ms: &[TokenTree]) -> usize {
295296}
296297
297298/// `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 > ] > {
299300 if len == 0 {
300301 vec ! [ ]
301302 } else {
302- let empty_matches = Rc :: new ( SmallVec :: new ( ) ) ;
303+ let empty_matches = Lrc :: new ( SmallVec :: new ( ) ) ;
303304 vec ! [ empty_matches; len]
304305 } . into_boxed_slice ( )
305306}
@@ -353,8 +354,8 @@ fn initial_matcher_pos<'root, 'tt>(ms: &'tt [TokenTree], open: Span) -> MatcherP
353354/// token tree it was derived from.
354355#[ derive( Debug , Clone ) ]
355356pub enum NamedMatch {
356- MatchedSeq ( Rc < NamedMatchVec > , DelimSpan ) ,
357- MatchedNonterminal ( Rc < Nonterminal > ) ,
357+ MatchedSeq ( Lrc < NamedMatchVec > , DelimSpan ) ,
358+ MatchedNonterminal ( Lrc < Nonterminal > ) ,
358359}
359360
360361/// Takes a sequence of token trees `ms` representing a matcher which successfully matched input
@@ -561,7 +562,7 @@ fn inner_parse_loop<'root, 'tt>(
561562 new_item. match_cur += seq. num_captures ;
562563 new_item. idx += 1 ;
563564 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) ) ;
565566 }
566567 cur_items. push ( new_item) ;
567568 }
@@ -707,7 +708,7 @@ pub fn parse(
707708 let matches = eof_items[ 0 ]
708709 . matches
709710 . iter_mut ( )
710- . map ( |dv| Rc :: make_mut ( dv) . pop ( ) . unwrap ( ) ) ;
711+ . map ( |dv| Lrc :: make_mut ( dv) . pop ( ) . unwrap ( ) ) ;
711712 return nameize ( sess, ms, matches) ;
712713 } else if eof_items. len ( ) > 1 {
713714 return Error (
@@ -780,7 +781,7 @@ pub fn parse(
780781 let match_cur = item. match_cur ;
781782 item. push_match (
782783 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 ( ) ) ) ) ,
784785 ) ;
785786 item. idx += 1 ;
786787 item. match_cur += 1 ;
@@ -829,7 +830,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool {
829830 } ,
830831 "block" => match * token {
831832 Token :: OpenDelim ( token:: Brace ) => true ,
832- Token :: Interpolated ( ref nt) => match nt . 0 {
833+ Token :: Interpolated ( ref nt) => match * * nt {
833834 token:: NtItem ( _)
834835 | token:: NtPat ( _)
835836 | token:: NtTy ( _)
@@ -843,9 +844,9 @@ fn may_begin_with(name: &str, token: &Token) -> bool {
843844 } ,
844845 "path" | "meta" => match * token {
845846 Token :: ModSep | Token :: Ident ( ..) => true ,
846- Token :: Interpolated ( ref nt) => match nt . 0 {
847+ Token :: Interpolated ( ref nt) => match * * nt {
847848 token:: NtPath ( _) | token:: NtMeta ( _) => true ,
848- _ => may_be_ident ( & nt. 0 ) ,
849+ _ => may_be_ident ( & nt) ,
849850 } ,
850851 _ => false ,
851852 } ,
@@ -862,12 +863,12 @@ fn may_begin_with(name: &str, token: &Token) -> bool {
862863 Token :: ModSep | // path
863864 Token :: Lt | // path (UFCS constant)
864865 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 ) ,
866867 _ => false ,
867868 } ,
868869 "lifetime" => match * token {
869870 Token :: Lifetime ( _) => true ,
870- Token :: Interpolated ( ref nt) => match nt . 0 {
871+ Token :: Interpolated ( ref nt) => match * * nt {
871872 token:: NtLifetime ( _) | token:: NtTT ( _) => true ,
872873 _ => false ,
873874 } ,
0 commit comments