File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -2680,8 +2680,9 @@ impl<'a> State<'a> {
2680
2680
ast_util:: int_ty_to_string ( st, Some ( i as i64 ) ) . as_slice ( ) )
2681
2681
}
2682
2682
ast:: SignedIntLit ( st, ast:: Minus ) => {
2683
+ let istr = ast_util:: int_ty_to_string ( st, Some ( -( i as i64 ) ) ) ;
2683
2684
word ( & mut self . s ,
2684
- ast_util :: int_ty_to_string ( st , Some ( - ( i as i64 ) ) ) . as_slice ( ) )
2685
+ format ! ( "-{}" , istr ) . as_slice ( ) )
2685
2686
}
2686
2687
ast:: UnsignedIntLit ( ut) => {
2687
2688
word ( & mut self . s , ast_util:: uint_ty_to_string ( ut, Some ( i) ) . as_slice ( ) )
@@ -2930,4 +2931,12 @@ mod test {
2930
2931
let varstr = variant_to_string ( & var) ;
2931
2932
assert_eq ! ( & varstr, & "pub principal_skinner" . to_string( ) ) ;
2932
2933
}
2934
+
2935
+ #[ test]
2936
+ fn test_signed_int_to_string ( ) {
2937
+ let pos_int = ast:: LitInt ( 42 , ast:: SignedIntLit ( ast:: TyI32 , ast:: Plus ) ) ;
2938
+ let neg_int = ast:: LitInt ( ( -42 ) as u64 , ast:: SignedIntLit ( ast:: TyI32 , ast:: Minus ) ) ;
2939
+ assert_eq ! ( format!( "-{}" , lit_to_string( & codemap:: dummy_spanned( pos_int) ) ) ,
2940
+ lit_to_string( & codemap:: dummy_spanned( neg_int) ) ) ;
2941
+ }
2933
2942
}
You can’t perform that action at this time.
0 commit comments