14
14
//! ownership of the original.
15
15
16
16
use std:: borrow:: Cow ;
17
+ use std:: sync:: Arc ;
17
18
use std:: { cmp, fmt, iter} ;
18
19
19
20
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
20
- use rustc_data_structures:: sync:: { self , Lrc } ;
21
+ use rustc_data_structures:: sync;
21
22
use rustc_macros:: { Decodable , Encodable , HashStable_Generic } ;
22
23
use rustc_serialize:: { Decodable , Encodable } ;
23
24
use rustc_span:: { DUMMY_SP , Span , SpanDecoder , SpanEncoder , Symbol , sym} ;
@@ -119,11 +120,11 @@ impl ToAttrTokenStream for AttrTokenStream {
119
120
/// of an actual `TokenStream` until it is needed.
120
121
/// `Box` is here only to reduce the structure size.
121
122
#[ derive( Clone ) ]
122
- pub struct LazyAttrTokenStream ( Lrc < Box < dyn ToAttrTokenStream > > ) ;
123
+ pub struct LazyAttrTokenStream ( Arc < Box < dyn ToAttrTokenStream > > ) ;
123
124
124
125
impl LazyAttrTokenStream {
125
126
pub fn new ( inner : impl ToAttrTokenStream + ' static ) -> LazyAttrTokenStream {
126
- LazyAttrTokenStream ( Lrc :: new ( Box :: new ( inner) ) )
127
+ LazyAttrTokenStream ( Arc :: new ( Box :: new ( inner) ) )
127
128
}
128
129
129
130
pub fn to_attr_token_stream ( & self ) -> AttrTokenStream {
@@ -160,7 +161,7 @@ impl<CTX> HashStable<CTX> for LazyAttrTokenStream {
160
161
/// during expansion to perform early cfg-expansion, and to process attributes
161
162
/// during proc-macro invocations.
162
163
#[ derive( Clone , Debug , Default , Encodable , Decodable ) ]
163
- pub struct AttrTokenStream ( pub Lrc < Vec < AttrTokenTree > > ) ;
164
+ pub struct AttrTokenStream ( pub Arc < Vec < AttrTokenTree > > ) ;
164
165
165
166
/// Like `TokenTree`, but for `AttrTokenStream`.
166
167
#[ derive( Clone , Debug , Encodable , Decodable ) ]
@@ -175,7 +176,7 @@ pub enum AttrTokenTree {
175
176
176
177
impl AttrTokenStream {
177
178
pub fn new ( tokens : Vec < AttrTokenTree > ) -> AttrTokenStream {
178
- AttrTokenStream ( Lrc :: new ( tokens) )
179
+ AttrTokenStream ( Arc :: new ( tokens) )
179
180
}
180
181
181
182
/// Converts this `AttrTokenStream` to a plain `Vec<TokenTree>`. During
@@ -293,7 +294,7 @@ pub struct AttrsTarget {
293
294
/// Today's `TokenTree`s can still contain AST via `token::Interpolated` for
294
295
/// backwards compatibility.
295
296
#[ derive( Clone , Debug , Default , Encodable , Decodable ) ]
296
- pub struct TokenStream ( pub ( crate ) Lrc < Vec < TokenTree > > ) ;
297
+ pub struct TokenStream ( pub ( crate ) Arc < Vec < TokenTree > > ) ;
297
298
298
299
/// Indicates whether a token can join with the following token to form a
299
300
/// compound token. Used for conversions to `proc_macro::Spacing`. Also used to
@@ -412,7 +413,7 @@ impl PartialEq<TokenStream> for TokenStream {
412
413
413
414
impl TokenStream {
414
415
pub fn new ( tts : Vec < TokenTree > ) -> TokenStream {
415
- TokenStream ( Lrc :: new ( tts) )
416
+ TokenStream ( Arc :: new ( tts) )
416
417
}
417
418
418
419
pub fn is_empty ( & self ) -> bool {
@@ -544,7 +545,7 @@ impl TokenStream {
544
545
/// Push `tt` onto the end of the stream, possibly gluing it to the last
545
546
/// token. Uses `make_mut` to maximize efficiency.
546
547
pub fn push_tree ( & mut self , tt : TokenTree ) {
547
- let vec_mut = Lrc :: make_mut ( & mut self . 0 ) ;
548
+ let vec_mut = Arc :: make_mut ( & mut self . 0 ) ;
548
549
549
550
if Self :: try_glue_to_last ( vec_mut, & tt) {
550
551
// nothing else to do
@@ -557,7 +558,7 @@ impl TokenStream {
557
558
/// token tree to the last token. (No other token trees will be glued.)
558
559
/// Uses `make_mut` to maximize efficiency.
559
560
pub fn push_stream ( & mut self , stream : TokenStream ) {
560
- let vec_mut = Lrc :: make_mut ( & mut self . 0 ) ;
561
+ let vec_mut = Arc :: make_mut ( & mut self . 0 ) ;
561
562
562
563
let stream_iter = stream. 0 . iter ( ) . cloned ( ) ;
563
564
@@ -577,7 +578,7 @@ impl TokenStream {
577
578
}
578
579
579
580
/// Desugar doc comments like `/// foo` in the stream into `#[doc =
580
- /// r"foo"]`. Modifies the `TokenStream` via `Lrc ::make_mut`, but as little
581
+ /// r"foo"]`. Modifies the `TokenStream` via `Arc ::make_mut`, but as little
581
582
/// as possible.
582
583
pub fn desugar_doc_comments ( & mut self ) {
583
584
if let Some ( desugared_stream) = desugar_inner ( self . clone ( ) ) {
@@ -596,7 +597,7 @@ impl TokenStream {
596
597
) => {
597
598
let desugared = desugared_tts ( attr_style, data, span) ;
598
599
let desugared_len = desugared. len ( ) ;
599
- Lrc :: make_mut ( & mut stream. 0 ) . splice ( i..i + 1 , desugared) ;
600
+ Arc :: make_mut ( & mut stream. 0 ) . splice ( i..i + 1 , desugared) ;
600
601
modified = true ;
601
602
i += desugared_len;
602
603
}
@@ -607,7 +608,7 @@ impl TokenStream {
607
608
if let Some ( desugared_delim_stream) = desugar_inner ( delim_stream. clone ( ) ) {
608
609
let new_tt =
609
610
TokenTree :: Delimited ( sp, spacing, delim, desugared_delim_stream) ;
610
- Lrc :: make_mut ( & mut stream. 0 ) [ i] = new_tt;
611
+ Arc :: make_mut ( & mut stream. 0 ) [ i] = new_tt;
611
612
modified = true ;
612
613
}
613
614
i += 1 ;
0 commit comments