43
43
//! [ts]: https://doc.rust-lang.org/proc_macro/struct.TokenStream.html
44
44
45
45
// Proc-macro2 types in rustdoc of other crates get linked to here.
46
- #![ doc( html_root_url = "https://docs.rs/proc-macro2/0.3.8 " ) ]
46
+ #![ doc( html_root_url = "https://docs.rs/proc-macro2/0.4.0 " ) ]
47
47
#![ cfg_attr( feature = "nightly" , feature( proc_macro) ) ]
48
48
49
49
#[ cfg( feature = "proc-macro" ) ]
@@ -284,26 +284,26 @@ impl fmt::Debug for Span {
284
284
#[ derive( Clone ) ]
285
285
pub enum TokenTree {
286
286
Group ( Group ) ,
287
- Term ( Term ) ,
288
- Op ( Op ) ,
287
+ Ident ( Ident ) ,
288
+ Punct ( Punct ) ,
289
289
Literal ( Literal ) ,
290
290
}
291
291
292
292
impl TokenTree {
293
293
pub fn span ( & self ) -> Span {
294
294
match * self {
295
295
TokenTree :: Group ( ref t) => t. span ( ) ,
296
- TokenTree :: Term ( ref t) => t. span ( ) ,
297
- TokenTree :: Op ( ref t) => t. span ( ) ,
296
+ TokenTree :: Ident ( ref t) => t. span ( ) ,
297
+ TokenTree :: Punct ( ref t) => t. span ( ) ,
298
298
TokenTree :: Literal ( ref t) => t. span ( ) ,
299
299
}
300
300
}
301
301
302
302
pub fn set_span ( & mut self , span : Span ) {
303
303
match * self {
304
304
TokenTree :: Group ( ref mut t) => t. set_span ( span) ,
305
- TokenTree :: Term ( ref mut t) => t. set_span ( span) ,
306
- TokenTree :: Op ( ref mut t) => t. set_span ( span) ,
305
+ TokenTree :: Ident ( ref mut t) => t. set_span ( span) ,
306
+ TokenTree :: Punct ( ref mut t) => t. set_span ( span) ,
307
307
TokenTree :: Literal ( ref mut t) => t. set_span ( span) ,
308
308
}
309
309
}
@@ -315,15 +315,15 @@ impl From<Group> for TokenTree {
315
315
}
316
316
}
317
317
318
- impl From < Term > for TokenTree {
319
- fn from ( g : Term ) -> TokenTree {
320
- TokenTree :: Term ( g)
318
+ impl From < Ident > for TokenTree {
319
+ fn from ( g : Ident ) -> TokenTree {
320
+ TokenTree :: Ident ( g)
321
321
}
322
322
}
323
323
324
- impl From < Op > for TokenTree {
325
- fn from ( g : Op ) -> TokenTree {
326
- TokenTree :: Op ( g)
324
+ impl From < Punct > for TokenTree {
325
+ fn from ( g : Punct ) -> TokenTree {
326
+ TokenTree :: Punct ( g)
327
327
}
328
328
}
329
329
@@ -337,8 +337,8 @@ impl fmt::Display for TokenTree {
337
337
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
338
338
match * self {
339
339
TokenTree :: Group ( ref t) => t. fmt ( f) ,
340
- TokenTree :: Term ( ref t) => t. fmt ( f) ,
341
- TokenTree :: Op ( ref t) => t. fmt ( f) ,
340
+ TokenTree :: Ident ( ref t) => t. fmt ( f) ,
341
+ TokenTree :: Punct ( ref t) => t. fmt ( f) ,
342
342
TokenTree :: Literal ( ref t) => t. fmt ( f) ,
343
343
}
344
344
}
@@ -350,8 +350,8 @@ impl fmt::Debug for TokenTree {
350
350
// so don't bother with an extra layer of indirection
351
351
match * self {
352
352
TokenTree :: Group ( ref t) => t. fmt ( f) ,
353
- TokenTree :: Term ( ref t) => t. fmt ( f) ,
354
- TokenTree :: Op ( ref t) => t. fmt ( f) ,
353
+ TokenTree :: Ident ( ref t) => t. fmt ( f) ,
354
+ TokenTree :: Punct ( ref t) => t. fmt ( f) ,
355
355
TokenTree :: Literal ( ref t) => t. fmt ( f) ,
356
356
}
357
357
}
@@ -416,7 +416,7 @@ impl fmt::Debug for Group {
416
416
}
417
417
418
418
#[ derive( Copy , Clone ) ]
419
- pub struct Op {
419
+ pub struct Punct {
420
420
op : char ,
421
421
spacing : Spacing ,
422
422
span : Span ,
@@ -428,16 +428,16 @@ pub enum Spacing {
428
428
Joint ,
429
429
}
430
430
431
- impl Op {
432
- pub fn new ( op : char , spacing : Spacing ) -> Op {
433
- Op {
431
+ impl Punct {
432
+ pub fn new ( op : char , spacing : Spacing ) -> Punct {
433
+ Punct {
434
434
op : op,
435
435
spacing : spacing,
436
436
span : Span :: call_site ( ) ,
437
437
}
438
438
}
439
439
440
- pub fn op ( & self ) -> char {
440
+ pub fn as_char ( & self ) -> char {
441
441
self . op
442
442
}
443
443
@@ -454,15 +454,15 @@ impl Op {
454
454
}
455
455
}
456
456
457
- impl fmt:: Display for Op {
457
+ impl fmt:: Display for Punct {
458
458
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
459
459
self . op . fmt ( f)
460
460
}
461
461
}
462
462
463
- impl fmt:: Debug for Op {
463
+ impl fmt:: Debug for Punct {
464
464
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
465
- let mut debug = fmt. debug_struct ( "Op " ) ;
465
+ let mut debug = fmt. debug_struct ( "Punct " ) ;
466
466
debug. field ( "op" , & self . op ) ;
467
467
debug. field ( "spacing" , & self . spacing ) ;
468
468
#[ cfg( procmacro2_semver_exempt) ]
@@ -471,26 +471,31 @@ impl fmt::Debug for Op {
471
471
}
472
472
}
473
473
474
- #[ derive( Copy , Clone ) ]
475
- pub struct Term {
476
- inner : imp:: Term ,
474
+ #[ derive( Clone ) ]
475
+ pub struct Ident {
476
+ inner : imp:: Ident ,
477
477
_marker : marker:: PhantomData < Rc < ( ) > > ,
478
478
}
479
479
480
- impl Term {
481
- fn _new ( inner : imp:: Term ) -> Term {
482
- Term {
480
+ impl Ident {
481
+ fn _new ( inner : imp:: Ident ) -> Ident {
482
+ Ident {
483
483
inner : inner,
484
484
_marker : marker:: PhantomData ,
485
485
}
486
486
}
487
487
488
- pub fn new ( string : & str , span : Span ) -> Term {
489
- Term :: _new ( imp:: Term :: new ( string, span. inner ) )
488
+ pub fn new ( string : & str , span : Span ) -> Ident {
489
+ Ident :: _new ( imp:: Ident :: new ( string, span. inner ) )
490
+ }
491
+
492
+ #[ cfg( procmacro2_semver_exempt) ]
493
+ pub fn new_raw ( string : & str , span : Span ) -> Ident {
494
+ Ident :: _new_raw ( string, span)
490
495
}
491
496
492
- pub fn as_str ( & self ) -> & str {
493
- self . inner . as_str ( )
497
+ fn _new_raw ( string : & str , span : Span ) -> Ident {
498
+ Ident :: _new ( imp :: Ident :: new_raw ( string , span . inner ) )
494
499
}
495
500
496
501
pub fn span ( & self ) -> Span {
@@ -502,13 +507,13 @@ impl Term {
502
507
}
503
508
}
504
509
505
- impl fmt:: Display for Term {
510
+ impl fmt:: Display for Ident {
506
511
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
507
- self . as_str ( ) . fmt ( f)
512
+ self . inner . fmt ( f)
508
513
}
509
514
}
510
515
511
- impl fmt:: Debug for Term {
516
+ impl fmt:: Debug for Ident {
512
517
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
513
518
self . inner . fmt ( f)
514
519
}
0 commit comments