@@ -88,6 +88,7 @@ use rustc_span::Span;
88
88
use std:: borrow:: Cow ;
89
89
use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
90
90
use std:: fmt:: Display ;
91
+ use std:: rc:: Rc ;
91
92
92
93
/// A unit within a matcher that a `MatcherPos` can refer to. Similar to (and derived from)
93
94
/// `mbe::TokenTree`, but designed specifically for fast and easy traversal during matching.
@@ -257,10 +258,10 @@ struct MatcherPos {
257
258
/// against the relevant metavar by the black box parser. An element will be a `MatchedSeq` if
258
259
/// the corresponding metavar decl is within a sequence.
259
260
///
260
- /// It is critical to performance that this is an `Lrc `, because it gets cloned frequently when
261
+ /// It is critical to performance that this is an `Rc `, because it gets cloned frequently when
261
262
/// processing sequences. Mostly for sequence-ending possibilities that must be tried but end
262
263
/// up failing.
263
- matches : Lrc < Vec < NamedMatch > > ,
264
+ matches : Rc < Vec < NamedMatch > > ,
264
265
}
265
266
266
267
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
@@ -272,7 +273,7 @@ impl MatcherPos {
272
273
/// and both are hot enough to be always worth inlining.
273
274
#[ inline( always) ]
274
275
fn push_match ( & mut self , metavar_idx : usize , seq_depth : usize , m : NamedMatch ) {
275
- let matches = Lrc :: make_mut ( & mut self . matches ) ;
276
+ let matches = Rc :: make_mut ( & mut self . matches ) ;
276
277
match seq_depth {
277
278
0 => {
278
279
// We are not within a sequence. Just append `m`.
@@ -427,7 +428,7 @@ pub struct TtParser {
427
428
428
429
/// Pre-allocate an empty match array, so it can be cloned cheaply for macros with many rules
429
430
/// that have no metavars.
430
- empty_matches : Lrc < Vec < NamedMatch > > ,
431
+ empty_matches : Rc < Vec < NamedMatch > > ,
431
432
}
432
433
433
434
impl TtParser {
@@ -437,7 +438,7 @@ impl TtParser {
437
438
cur_mps : vec ! [ ] ,
438
439
next_mps : vec ! [ ] ,
439
440
bb_mps : vec ! [ ] ,
440
- empty_matches : Lrc :: new ( vec ! [ ] ) ,
441
+ empty_matches : Rc :: new ( vec ! [ ] ) ,
441
442
}
442
443
}
443
444
@@ -507,7 +508,7 @@ impl TtParser {
507
508
// Try zero matches of this sequence, by skipping over it.
508
509
self . cur_mps . push ( MatcherPos {
509
510
idx : idx_first_after,
510
- matches : Lrc :: clone ( & mp. matches ) ,
511
+ matches : Rc :: clone ( & mp. matches ) ,
511
512
} ) ;
512
513
}
513
514
@@ -521,7 +522,7 @@ impl TtParser {
521
522
// processed next time around the loop.
522
523
let ending_mp = MatcherPos {
523
524
idx : mp. idx + 1 , // +1 skips the Kleene op
524
- matches : Lrc :: clone ( & mp. matches ) ,
525
+ matches : Rc :: clone ( & mp. matches ) ,
525
526
} ;
526
527
self . cur_mps . push ( ending_mp) ;
527
528
@@ -537,7 +538,7 @@ impl TtParser {
537
538
// will fail quietly when it is processed next time around the loop.
538
539
let ending_mp = MatcherPos {
539
540
idx : mp. idx + 2 , // +2 skips the separator and the Kleene op
540
- matches : Lrc :: clone ( & mp. matches ) ,
541
+ matches : Rc :: clone ( & mp. matches ) ,
541
542
} ;
542
543
self . cur_mps . push ( ending_mp) ;
543
544
@@ -587,9 +588,9 @@ impl TtParser {
587
588
if * token == token:: Eof {
588
589
Some ( match eof_mps {
589
590
EofMatcherPositions :: One ( mut eof_mp) => {
590
- // Need to take ownership of the matches from within the `Lrc `.
591
- Lrc :: make_mut ( & mut eof_mp. matches ) ;
592
- let matches = Lrc :: try_unwrap ( eof_mp. matches ) . unwrap ( ) . into_iter ( ) ;
591
+ // Need to take ownership of the matches from within the `Rc `.
592
+ Rc :: make_mut ( & mut eof_mp. matches ) ;
593
+ let matches = Rc :: try_unwrap ( eof_mp. matches ) . unwrap ( ) . into_iter ( ) ;
593
594
self . nameize ( matcher, matches)
594
595
}
595
596
EofMatcherPositions :: Multiple => {
0 commit comments