@@ -56,6 +56,8 @@ macro_rules! with_api {
56
56
fn drop( $self: $S:: FreeFunctions ) ;
57
57
fn track_env_var( var: & str , value: Option <& str >) ;
58
58
fn track_path( path: & str ) ;
59
+ fn literal_from_str( s: & str ) -> Result <Literal <$S:: Span , $S:: Symbol >, ( ) >;
60
+ fn literal_subspan( lit: Literal <$S:: Span , $S:: Symbol >, start: Bound <usize >, end: Bound <usize >) -> Option <$S:: Span >;
59
61
} ,
60
62
TokenStream {
61
63
fn drop( $self: $S:: TokenStream ) ;
@@ -65,43 +67,19 @@ macro_rules! with_api {
65
67
fn from_str( src: & str ) -> $S:: TokenStream ;
66
68
fn to_string( $self: & $S:: TokenStream ) -> String ;
67
69
fn from_token_tree(
68
- tree: TokenTree <$S:: TokenStream , $S:: Span , $S:: Symbol , $S :: Literal >,
70
+ tree: TokenTree <$S:: TokenStream , $S:: Span , $S:: Symbol >,
69
71
) -> $S:: TokenStream ;
70
72
fn concat_trees(
71
73
base: Option <$S:: TokenStream >,
72
- trees: Vec <TokenTree <$S:: TokenStream , $S:: Span , $S:: Symbol , $S :: Literal >>,
74
+ trees: Vec <TokenTree <$S:: TokenStream , $S:: Span , $S:: Symbol >>,
73
75
) -> $S:: TokenStream ;
74
76
fn concat_streams(
75
77
base: Option <$S:: TokenStream >,
76
78
streams: Vec <$S:: TokenStream >,
77
79
) -> $S:: TokenStream ;
78
80
fn into_trees(
79
81
$self: $S:: TokenStream
80
- ) -> Vec <TokenTree <$S:: TokenStream , $S:: Span , $S:: Symbol , $S:: Literal >>;
81
- } ,
82
- Literal {
83
- fn drop( $self: $S:: Literal ) ;
84
- fn clone( $self: & $S:: Literal ) -> $S:: Literal ;
85
- fn from_str( s: & str ) -> Result <$S:: Literal , ( ) >;
86
- fn to_string( $self: & $S:: Literal ) -> String ;
87
- fn debug_kind( $self: & $S:: Literal ) -> String ;
88
- fn symbol( $self: & $S:: Literal ) -> String ;
89
- fn suffix( $self: & $S:: Literal ) -> Option <String >;
90
- fn integer( n: & str ) -> $S:: Literal ;
91
- fn typed_integer( n: & str , kind: & str ) -> $S:: Literal ;
92
- fn float( n: & str ) -> $S:: Literal ;
93
- fn f32 ( n: & str ) -> $S:: Literal ;
94
- fn f64 ( n: & str ) -> $S:: Literal ;
95
- fn string( string: & str ) -> $S:: Literal ;
96
- fn character( ch: char ) -> $S:: Literal ;
97
- fn byte_string( bytes: & [ u8 ] ) -> $S:: Literal ;
98
- fn span( $self: & $S:: Literal ) -> $S:: Span ;
99
- fn set_span( $self: & mut $S:: Literal , span: $S:: Span ) ;
100
- fn subspan(
101
- $self: & $S:: Literal ,
102
- start: Bound <usize >,
103
- end: Bound <usize >,
104
- ) -> Option <$S:: Span >;
82
+ ) -> Vec <TokenTree <$S:: TokenStream , $S:: Span , $S:: Symbol >>;
105
83
} ,
106
84
SourceFile {
107
85
fn drop( $self: $S:: SourceFile ) ;
@@ -332,6 +310,7 @@ mark_noop! {
332
310
u8 ,
333
311
usize ,
334
312
Delimiter ,
313
+ LitKind ,
335
314
Level ,
336
315
LineColumn ,
337
316
Spacing ,
@@ -361,6 +340,33 @@ rpc_encode_decode!(
361
340
}
362
341
) ;
363
342
343
+ #[ derive( Copy , Clone , Eq , PartialEq , Debug ) ]
344
+ pub enum LitKind {
345
+ Byte ,
346
+ Char ,
347
+ Integer ,
348
+ Float ,
349
+ Str ,
350
+ StrRaw ( u8 ) ,
351
+ ByteStr ,
352
+ ByteStrRaw ( u8 ) ,
353
+ Err ,
354
+ }
355
+
356
+ rpc_encode_decode ! (
357
+ enum LitKind {
358
+ Byte ,
359
+ Char ,
360
+ Integer ,
361
+ Float ,
362
+ Str ,
363
+ StrRaw ( n) ,
364
+ ByteStr ,
365
+ ByteStrRaw ( n) ,
366
+ Err ,
367
+ }
368
+ ) ;
369
+
364
370
macro_rules! mark_compound {
365
371
( struct $name: ident <$( $T: ident) ,+> { $( $field: ident) ,* $( , ) ? } ) => {
366
372
impl <$( $T: Mark ) ,+> Mark for $name <$( $T) ,+> {
@@ -477,16 +483,26 @@ pub struct Ident<Span, Symbol> {
477
483
478
484
compound_traits ! ( struct Ident <Span , Symbol > { sym, is_raw, span } ) ;
479
485
486
+ #[ derive( Clone , Eq , PartialEq ) ]
487
+ pub struct Literal < Span , Symbol > {
488
+ pub kind : LitKind ,
489
+ pub symbol : Symbol ,
490
+ pub suffix : Option < Symbol > ,
491
+ pub span : Span ,
492
+ }
493
+
494
+ compound_traits ! ( struct Literal <Sp , Sy > { kind, symbol, suffix, span } ) ;
495
+
480
496
#[ derive( Clone ) ]
481
- pub enum TokenTree < TokenStream , Span , Symbol , Literal > {
497
+ pub enum TokenTree < TokenStream , Span , Symbol > {
482
498
Group ( Group < TokenStream , Span > ) ,
483
499
Punct ( Punct < Span > ) ,
484
500
Ident ( Ident < Span , Symbol > ) ,
485
- Literal ( Literal ) ,
501
+ Literal ( Literal < Span , Symbol > ) ,
486
502
}
487
503
488
504
compound_traits ! (
489
- enum TokenTree <TokenStream , Span , Symbol , Literal > {
505
+ enum TokenTree <TokenStream , Span , Symbol > {
490
506
Group ( tt) ,
491
507
Punct ( tt) ,
492
508
Ident ( tt) ,
0 commit comments