diff options
Diffstat (limited to 'crates/proc_macro_srv/src')
-rw-r--r-- | crates/proc_macro_srv/src/rustc_server.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/crates/proc_macro_srv/src/rustc_server.rs b/crates/proc_macro_srv/src/rustc_server.rs index c147484c0..5d765f6e2 100644 --- a/crates/proc_macro_srv/src/rustc_server.rs +++ b/crates/proc_macro_srv/src/rustc_server.rs | |||
@@ -534,8 +534,12 @@ impl server::Literal for Rustc { | |||
534 | } | 534 | } |
535 | 535 | ||
536 | fn integer(&mut self, n: &str) -> Self::Literal { | 536 | fn integer(&mut self, n: &str) -> Self::Literal { |
537 | let n: i128 = n.parse().unwrap(); | 537 | let n = if let Ok(n) = n.parse::<i128>() { |
538 | Literal { text: n.to_string().into(), id: tt::TokenId::unspecified() } | 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 | fn typed_integer(&mut self, n: &str, kind: &str) -> Self::Literal { | 545 | fn typed_integer(&mut self, n: &str, kind: &str) -> Self::Literal { |
@@ -757,6 +761,17 @@ mod tests { | |||
757 | assert_eq!(srv.string("hello_world").text, "\"hello_world\""); | 761 | assert_eq!(srv.string("hello_world").text, "\"hello_world\""); |
758 | assert_eq!(srv.character('c').text, "'c'"); | 762 | assert_eq!(srv.character('c').text, "'c'"); |
759 | assert_eq!(srv.byte_string(b"1234586\x88").text, "b\"1234586\\x88\""); | 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 | #[test] | 777 | #[test] |