File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
crates/proc_macro_srv/src Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -534,8 +534,12 @@ impl server::Literal for Rustc {
534
534
}
535
535
536
536
fn integer ( & mut self , n : & str ) -> Self :: Literal {
537
- let n: i128 = n. parse ( ) . unwrap ( ) ;
538
- Literal { text : n. to_string ( ) . into ( ) , id : tt:: TokenId :: unspecified ( ) }
537
+ let n = if let Ok ( n) = n. parse :: < i128 > ( ) {
538
+ n. to_string ( )
539
+ } else {
540
+ n. parse :: < u128 > ( ) . unwrap ( ) . to_string ( )
541
+ } ;
542
+ return Literal { text : n. into ( ) , id : tt:: TokenId :: unspecified ( ) } ;
539
543
}
540
544
541
545
fn typed_integer ( & mut self , n : & str , kind : & str ) -> Self :: Literal {
@@ -757,6 +761,17 @@ mod tests {
757
761
assert_eq ! ( srv. string( "hello_world" ) . text, "\" hello_world\" " ) ;
758
762
assert_eq ! ( srv. character( 'c' ) . text, "'c'" ) ;
759
763
assert_eq ! ( srv. byte_string( b"1234586\x88 " ) . text, "b\" 1234586\\ x88\" " ) ;
764
+
765
+ // u128::max
766
+ assert_eq ! (
767
+ srv. integer( "340282366920938463463374607431768211455" ) . text,
768
+ "340282366920938463463374607431768211455"
769
+ ) ;
770
+ // i128::min
771
+ assert_eq ! (
772
+ srv. integer( "-170141183460469231731687303715884105728" ) . text,
773
+ "-170141183460469231731687303715884105728"
774
+ ) ;
760
775
}
761
776
762
777
#[ test]
You can’t perform that action at this time.
0 commit comments