File tree 4 files changed +8
-4
lines changed
compiler/rustc_expand/src
src/test/ui/proc-macro/auxiliary/api
4 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -582,6 +582,9 @@ impl server::Literal for Rustc<'_> {
582
582
583
583
Ok ( Literal { lit, span : self . call_site } )
584
584
}
585
+ fn to_string ( & mut self , literal : & Self :: Literal ) -> String {
586
+ literal. lit . to_string ( )
587
+ }
585
588
fn debug_kind ( & mut self , literal : & Self :: Literal ) -> String {
586
589
format ! ( "{:?}" , literal. lit. kind)
587
590
}
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ macro_rules! with_api {
109
109
fn drop( $self: $S:: Literal ) ;
110
110
fn clone( $self: & $S:: Literal ) -> $S:: Literal ;
111
111
fn from_str( s: & str ) -> Result <$S:: Literal , ( ) >;
112
+ fn to_string( $self: & $S:: Literal ) -> String ;
112
113
fn debug_kind( $self: & $S:: Literal ) -> String ;
113
114
fn symbol( $self: & $S:: Literal ) -> String ;
114
115
fn suffix( $self: & $S:: Literal ) -> Option <String >;
Original file line number Diff line number Diff line change @@ -1195,7 +1195,7 @@ impl FromStr for Literal {
1195
1195
#[ stable( feature = "proc_macro_lib" , since = "1.15.0" ) ]
1196
1196
impl ToString for Literal {
1197
1197
fn to_string ( & self ) -> String {
1198
- TokenStream :: from ( TokenTree :: from ( self . clone ( ) ) ) . to_string ( )
1198
+ self . 0 . to_string ( )
1199
1199
}
1200
1200
}
1201
1201
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ pub fn test() {
6
6
}
7
7
8
8
fn test_display_literal ( ) {
9
- assert_eq ! ( Literal :: isize_unsuffixed( -10 ) . to_string( ) , "- 10" ) ;
10
- assert_eq ! ( Literal :: isize_suffixed( -10 ) . to_string( ) , "- 10isize" ) ;
9
+ assert_eq ! ( Literal :: isize_unsuffixed( -10 ) . to_string( ) , "-10" ) ;
10
+ assert_eq ! ( Literal :: isize_suffixed( -10 ) . to_string( ) , "-10isize" ) ;
11
11
}
12
12
13
13
fn test_parse_literal ( ) {
@@ -18,7 +18,7 @@ fn test_parse_literal() {
18
18
assert_eq ! ( "b\" \" " . parse:: <Literal >( ) . unwrap( ) . to_string( ) , "b\" \" " ) ;
19
19
assert_eq ! ( "r##\" \" ##" . parse:: <Literal >( ) . unwrap( ) . to_string( ) , "r##\" \" ##" ) ;
20
20
assert_eq ! ( "10ulong" . parse:: <Literal >( ) . unwrap( ) . to_string( ) , "10ulong" ) ;
21
- assert_eq ! ( "-10ulong" . parse:: <Literal >( ) . unwrap( ) . to_string( ) , "- 10ulong" ) ;
21
+ assert_eq ! ( "-10ulong" . parse:: <Literal >( ) . unwrap( ) . to_string( ) , "-10ulong" ) ;
22
22
23
23
assert ! ( "true" . parse:: <Literal >( ) . is_err( ) ) ;
24
24
assert ! ( ".8" . parse:: <Literal >( ) . is_err( ) ) ;
You can’t perform that action at this time.
0 commit comments