@@ -65,7 +65,7 @@ impl FromStr for TokenStream {
65
65
if skip_whitespace ( input) . len ( ) != 0 {
66
66
Err ( LexError )
67
67
} else {
68
- Ok ( output. inner )
68
+ Ok ( output)
69
69
}
70
70
}
71
71
Err ( LexError ) => Err ( LexError ) ,
@@ -89,7 +89,7 @@ impl fmt::Display for TokenStream {
89
89
Delimiter :: Bracket => ( "[" , "]" ) ,
90
90
Delimiter :: None => ( "" , "" ) ,
91
91
} ;
92
- if tt. stream ( ) . inner . inner . len ( ) == 0 {
92
+ if tt. stream ( ) . into_iter ( ) . next ( ) . is_none ( ) {
93
93
write ! ( f, "{} {}" , start, end) ?
94
94
} else {
95
95
write ! ( f, "{} {} {}" , start, tt. stream( ) , end) ?
@@ -167,24 +167,24 @@ impl IntoIterator for TokenStream {
167
167
}
168
168
}
169
169
170
- #[ cfg( procmacro2_semver_exempt) ]
171
170
#[ derive( Clone , PartialEq , Eq , Debug ) ]
172
171
pub struct FileName ( String ) ;
173
172
174
- #[ cfg( procmacro2_semver_exempt) ]
173
+ pub fn file_name ( s : String ) -> FileName {
174
+ FileName ( s)
175
+ }
176
+
175
177
impl fmt:: Display for FileName {
176
178
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
177
179
self . 0 . fmt ( f)
178
180
}
179
181
}
180
182
181
- #[ cfg( procmacro2_semver_exempt) ]
182
183
#[ derive( Clone , PartialEq , Eq ) ]
183
184
pub struct SourceFile {
184
185
name : FileName ,
185
186
}
186
187
187
- #[ cfg( procmacro2_semver_exempt) ]
188
188
impl SourceFile {
189
189
/// Get the path to this source file as a string.
190
190
pub fn path ( & self ) -> & FileName {
@@ -197,14 +197,12 @@ impl SourceFile {
197
197
}
198
198
}
199
199
200
- #[ cfg( procmacro2_semver_exempt) ]
201
200
impl AsRef < FileName > for SourceFile {
202
201
fn as_ref ( & self ) -> & FileName {
203
202
self . path ( )
204
203
}
205
204
}
206
205
207
- #[ cfg( procmacro2_semver_exempt) ]
208
206
impl fmt:: Debug for SourceFile {
209
207
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
210
208
f. debug_struct ( "SourceFile" )
@@ -214,7 +212,6 @@ impl fmt::Debug for SourceFile {
214
212
}
215
213
}
216
214
217
- #[ cfg( procmacro2_semver_exempt) ]
218
215
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
219
216
pub struct LineColumn {
220
217
pub line : usize ,
@@ -660,7 +657,7 @@ impl fmt::Debug for Literal {
660
657
}
661
658
}
662
659
663
- fn token_stream ( mut input : Cursor ) -> PResult < :: TokenStream > {
660
+ fn token_stream ( mut input : Cursor ) -> PResult < TokenStream > {
664
661
let mut trees = Vec :: new ( ) ;
665
662
loop {
666
663
let input_no_ws = skip_whitespace ( input) ;
@@ -680,7 +677,7 @@ fn token_stream(mut input: Cursor) -> PResult<::TokenStream> {
680
677
trees. push ( tt) ;
681
678
input = a;
682
679
}
683
- Ok ( ( input, :: TokenStream :: _new ( TokenStream { inner : trees } ) ) )
680
+ Ok ( ( input, TokenStream { inner : trees } ) )
684
681
}
685
682
686
683
#[ cfg( not( procmacro2_semver_exempt) ) ]
@@ -689,7 +686,7 @@ fn spanned<'a, T>(
689
686
f : fn ( Cursor < ' a > ) -> PResult < ' a , T > ,
690
687
) -> PResult < ' a , ( T , :: Span ) > {
691
688
let ( a, b) = f ( skip_whitespace ( input) ) ?;
692
- Ok ( ( a, ( ( b, :: Span :: _new ( Span { } ) ) ) ) )
689
+ Ok ( ( a, ( ( b, :: Span :: _new_stable ( Span { } ) ) ) ) )
693
690
}
694
691
695
692
#[ cfg( procmacro2_semver_exempt) ]
@@ -701,7 +698,7 @@ fn spanned<'a, T>(
701
698
let lo = input. off ;
702
699
let ( a, b) = f ( input) ?;
703
700
let hi = a. off ;
704
- let span = :: Span :: _new ( Span { lo : lo, hi : hi } ) ;
701
+ let span = :: Span :: _new_stable ( Span { lo : lo, hi : hi } ) ;
705
702
Ok ( ( a, ( b, span) ) )
706
703
}
707
704
@@ -714,7 +711,7 @@ fn token_tree(input: Cursor) -> PResult<TokenTree> {
714
711
named ! ( token_kind -> TokenTree , alt!(
715
712
map!( group, TokenTree :: Group )
716
713
|
717
- map!( literal, TokenTree :: Literal ) // must be before symbol
714
+ map!( literal, |l| TokenTree :: Literal ( :: Literal :: _new_stable ( l ) ) ) // must be before symbol
718
715
|
719
716
symbol
720
717
|
@@ -726,19 +723,19 @@ named!(group -> Group, alt!(
726
723
punct!( "(" ) ,
727
724
token_stream,
728
725
punct!( ")" )
729
- ) => { |ts| Group :: new( Delimiter :: Parenthesis , ts ) }
726
+ ) => { |ts| Group :: new( Delimiter :: Parenthesis , :: TokenStream :: _new_stable ( ts ) ) }
730
727
|
731
728
delimited!(
732
729
punct!( "[" ) ,
733
730
token_stream,
734
731
punct!( "]" )
735
- ) => { |ts| Group :: new( Delimiter :: Bracket , ts ) }
732
+ ) => { |ts| Group :: new( Delimiter :: Bracket , :: TokenStream :: _new_stable ( ts ) ) }
736
733
|
737
734
delimited!(
738
735
punct!( "{" ) ,
739
736
token_stream,
740
737
punct!( "}" )
741
- ) => { |ts| Group :: new( Delimiter :: Brace , ts ) }
738
+ ) => { |ts| Group :: new( Delimiter :: Brace , :: TokenStream :: _new_stable ( ts ) ) }
742
739
) ) ;
743
740
744
741
fn symbol ( mut input : Cursor ) -> PResult < TokenTree > {
@@ -792,7 +789,7 @@ static KEYWORDS: &'static [&'static str] = &[
792
789
"type" , "typeof" , "unsafe" , "unsized" , "use" , "virtual" , "where" , "while" , "yield" ,
793
790
] ;
794
791
795
- fn literal ( input : Cursor ) -> PResult < :: Literal > {
792
+ fn literal ( input : Cursor ) -> PResult < Literal > {
796
793
let input_no_ws = skip_whitespace ( input) ;
797
794
798
795
match literal_nocapture ( input_no_ws) {
@@ -802,7 +799,7 @@ fn literal(input: Cursor) -> PResult<::Literal> {
802
799
let end = start + len;
803
800
Ok ( (
804
801
a,
805
- :: Literal :: _new ( Literal :: _new ( input. rest [ start..end] . to_string ( ) ) ) ,
802
+ Literal :: _new ( input. rest [ start..end] . to_string ( ) ) ,
806
803
) )
807
804
}
808
805
Err ( LexError ) => Err ( LexError ) ,
0 commit comments