11use std:: ascii;
22use std:: borrow:: Borrow ;
33use std:: cell:: RefCell ;
4- #[ cfg( procmacro2_unstable ) ]
4+ #[ cfg( procmacro2_semver_exempt ) ]
55use std:: cmp;
66use std:: collections:: HashMap ;
77use std:: fmt;
@@ -36,7 +36,7 @@ impl TokenStream {
3636 }
3737}
3838
39- #[ cfg( procmacro2_unstable ) ]
39+ #[ cfg( procmacro2_semver_exempt ) ]
4040fn get_cursor ( src : & str ) -> Cursor {
4141 // Create a dummy file & add it to the codemap
4242 CODEMAP . with ( |cm| {
@@ -50,7 +50,7 @@ fn get_cursor(src: &str) -> Cursor {
5050 } )
5151}
5252
53- #[ cfg( not( procmacro2_unstable ) ) ]
53+ #[ cfg( not( procmacro2_semver_exempt ) ) ]
5454fn get_cursor ( src : & str ) -> Cursor {
5555 Cursor {
5656 rest : src,
@@ -163,24 +163,24 @@ impl IntoIterator for TokenStream {
163163 }
164164}
165165
166- #[ cfg( procmacro2_unstable ) ]
166+ #[ cfg( procmacro2_semver_exempt ) ]
167167#[ derive( Clone , PartialEq , Eq , Debug ) ]
168168pub struct FileName ( String ) ;
169169
170- #[ cfg( procmacro2_unstable ) ]
170+ #[ cfg( procmacro2_semver_exempt ) ]
171171impl fmt:: Display for FileName {
172172 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
173173 self . 0 . fmt ( f)
174174 }
175175}
176176
177- #[ cfg( procmacro2_unstable ) ]
177+ #[ cfg( procmacro2_semver_exempt ) ]
178178#[ derive( Clone , PartialEq , Eq ) ]
179179pub struct SourceFile {
180180 name : FileName ,
181181}
182182
183- #[ cfg( procmacro2_unstable ) ]
183+ #[ cfg( procmacro2_semver_exempt ) ]
184184impl SourceFile {
185185 /// Get the path to this source file as a string.
186186 pub fn path ( & self ) -> & FileName {
@@ -193,14 +193,14 @@ impl SourceFile {
193193 }
194194}
195195
196- #[ cfg( procmacro2_unstable ) ]
196+ #[ cfg( procmacro2_semver_exempt ) ]
197197impl AsRef < FileName > for SourceFile {
198198 fn as_ref ( & self ) -> & FileName {
199199 self . path ( )
200200 }
201201}
202202
203- #[ cfg( procmacro2_unstable ) ]
203+ #[ cfg( procmacro2_semver_exempt ) ]
204204impl fmt:: Debug for SourceFile {
205205 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
206206 f. debug_struct ( "SourceFile" )
@@ -210,14 +210,14 @@ impl fmt::Debug for SourceFile {
210210 }
211211}
212212
213- #[ cfg( procmacro2_unstable ) ]
213+ #[ cfg( procmacro2_semver_exempt ) ]
214214#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
215215pub struct LineColumn {
216216 pub line : usize ,
217217 pub column : usize ,
218218}
219219
220- #[ cfg( procmacro2_unstable ) ]
220+ #[ cfg( procmacro2_semver_exempt ) ]
221221thread_local ! {
222222 static CODEMAP : RefCell <Codemap > = RefCell :: new( Codemap {
223223 // NOTE: We start with a single dummy file which all call_site() and
@@ -230,14 +230,14 @@ thread_local! {
230230 } ) ;
231231}
232232
233- #[ cfg( procmacro2_unstable ) ]
233+ #[ cfg( procmacro2_semver_exempt ) ]
234234struct FileInfo {
235235 name : String ,
236236 span : Span ,
237237 lines : Vec < usize > ,
238238}
239239
240- #[ cfg( procmacro2_unstable ) ]
240+ #[ cfg( procmacro2_semver_exempt ) ]
241241impl FileInfo {
242242 fn offset_line_column ( & self , offset : usize ) -> LineColumn {
243243 assert ! ( self . span_within( Span { lo: offset as u32 , hi: offset as u32 } ) ) ;
@@ -260,7 +260,7 @@ impl FileInfo {
260260}
261261
262262/// Computes the offsets of each line in the given source string.
263- #[ cfg( procmacro2_unstable ) ]
263+ #[ cfg( procmacro2_semver_exempt ) ]
264264fn lines_offsets ( s : & str ) -> Vec < usize > {
265265 let mut lines = vec ! [ 0 ] ;
266266 let mut prev = 0 ;
@@ -271,12 +271,12 @@ fn lines_offsets(s: &str) -> Vec<usize> {
271271 lines
272272}
273273
274- #[ cfg( procmacro2_unstable ) ]
274+ #[ cfg( procmacro2_semver_exempt ) ]
275275struct Codemap {
276276 files : Vec < FileInfo > ,
277277}
278278
279- #[ cfg( procmacro2_unstable ) ]
279+ #[ cfg( procmacro2_semver_exempt ) ]
280280impl Codemap {
281281 fn next_start_pos ( & self ) -> u32 {
282282 // Add 1 so there's always space between files.
@@ -313,19 +313,19 @@ impl Codemap {
313313
314314#[ derive( Clone , Copy , Debug ) ]
315315pub struct Span {
316- #[ cfg( procmacro2_unstable ) ]
316+ #[ cfg( procmacro2_semver_exempt ) ]
317317 lo : u32 ,
318- #[ cfg( procmacro2_unstable ) ]
318+ #[ cfg( procmacro2_semver_exempt ) ]
319319 hi : u32 ,
320320}
321321
322322impl Span {
323- #[ cfg( not( procmacro2_unstable ) ) ]
323+ #[ cfg( not( procmacro2_semver_exempt ) ) ]
324324 pub fn call_site ( ) -> Span {
325325 Span { }
326326 }
327327
328- #[ cfg( procmacro2_unstable ) ]
328+ #[ cfg( procmacro2_semver_exempt ) ]
329329 pub fn call_site ( ) -> Span {
330330 Span { lo : 0 , hi : 0 }
331331 }
@@ -334,7 +334,7 @@ impl Span {
334334 Span :: call_site ( )
335335 }
336336
337- #[ cfg( procmacro2_unstable ) ]
337+ #[ cfg( procmacro2_semver_exempt ) ]
338338 pub fn source_file ( & self ) -> SourceFile {
339339 CODEMAP . with ( |cm| {
340340 let cm = cm. borrow ( ) ;
@@ -345,7 +345,7 @@ impl Span {
345345 } )
346346 }
347347
348- #[ cfg( procmacro2_unstable ) ]
348+ #[ cfg( procmacro2_semver_exempt ) ]
349349 pub fn start ( & self ) -> LineColumn {
350350 CODEMAP . with ( |cm| {
351351 let cm = cm. borrow ( ) ;
@@ -354,7 +354,7 @@ impl Span {
354354 } )
355355 }
356356
357- #[ cfg( procmacro2_unstable ) ]
357+ #[ cfg( procmacro2_semver_exempt ) ]
358358 pub fn end ( & self ) -> LineColumn {
359359 CODEMAP . with ( |cm| {
360360 let cm = cm. borrow ( ) ;
@@ -363,7 +363,7 @@ impl Span {
363363 } )
364364 }
365365
366- #[ cfg( procmacro2_unstable ) ]
366+ #[ cfg( procmacro2_semver_exempt ) ]
367367 pub fn join ( & self , other : Span ) -> Option < Span > {
368368 CODEMAP . with ( |cm| {
369369 let cm = cm. borrow ( ) ;
@@ -578,7 +578,7 @@ named!(token_stream -> ::TokenStream, map!(
578578 |trees| :: TokenStream ( TokenStream { inner: trees } )
579579) ) ;
580580
581- #[ cfg( not( procmacro2_unstable ) ) ]
581+ #[ cfg( not( procmacro2_semver_exempt ) ) ]
582582fn token_tree ( input : Cursor ) -> PResult < TokenTree > {
583583 let ( input, kind) = token_kind ( input) ?;
584584 Ok ( ( input, TokenTree {
@@ -587,7 +587,7 @@ fn token_tree(input: Cursor) -> PResult<TokenTree> {
587587 } ) )
588588}
589589
590- #[ cfg( procmacro2_unstable ) ]
590+ #[ cfg( procmacro2_semver_exempt ) ]
591591fn token_tree ( input : Cursor ) -> PResult < TokenTree > {
592592 let input = skip_whitespace ( input) ;
593593 let lo = input. off ;
0 commit comments