File tree Expand file tree Collapse file tree 4 files changed +8
-4
lines changed
compiler/rustc_expand/src
src/test/ui/proc-macro/auxiliary/api Expand file tree Collapse file tree 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<'_> {
582582
583583 Ok ( Literal { lit, span : self . call_site } )
584584 }
585+ fn to_string ( & mut self , literal : & Self :: Literal ) -> String {
586+ literal. lit . to_string ( )
587+ }
585588 fn debug_kind ( & mut self , literal : & Self :: Literal ) -> String {
586589 format ! ( "{:?}" , literal. lit. kind)
587590 }
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ macro_rules! with_api {
109109 fn drop( $self: $S:: Literal ) ;
110110 fn clone( $self: & $S:: Literal ) -> $S:: Literal ;
111111 fn from_str( s: & str ) -> Result <$S:: Literal , ( ) >;
112+ fn to_string( $self: & $S:: Literal ) -> String ;
112113 fn debug_kind( $self: & $S:: Literal ) -> String ;
113114 fn symbol( $self: & $S:: Literal ) -> String ;
114115 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 {
11951195#[ stable( feature = "proc_macro_lib" , since = "1.15.0" ) ]
11961196impl ToString for Literal {
11971197 fn to_string ( & self ) -> String {
1198- TokenStream :: from ( TokenTree :: from ( self . clone ( ) ) ) . to_string ( )
1198+ self . 0 . to_string ( )
11991199 }
12001200}
12011201
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ pub fn test() {
66}
77
88fn 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" ) ;
1111}
1212
1313fn test_parse_literal ( ) {
@@ -18,7 +18,7 @@ fn test_parse_literal() {
1818 assert_eq ! ( "b\" \" " . parse:: <Literal >( ) . unwrap( ) . to_string( ) , "b\" \" " ) ;
1919 assert_eq ! ( "r##\" \" ##" . parse:: <Literal >( ) . unwrap( ) . to_string( ) , "r##\" \" ##" ) ;
2020 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" ) ;
2222
2323 assert ! ( "true" . parse:: <Literal >( ) . is_err( ) ) ;
2424 assert ! ( ".8" . parse:: <Literal >( ) . is_err( ) ) ;
You can’t perform that action at this time.
0 commit comments