Avoid some code duplication around getting names of numeric types.

This commit is contained in:
Michael Woerister
2015-11-23 15:59:36 +01:00
parent 4891c00634
commit 3be1d8ca7d
6 changed files with 44 additions and 110 deletions

View File

@@ -651,15 +651,15 @@ pub trait PrintState<'a> {
match t {
ast::SignedIntLit(st, ast::Plus) => {
word(self.writer(),
&ast_util::int_ty_to_string(st, Some(i as i64)))
&ast_util::int_val_to_string(st, i as i64))
}
ast::SignedIntLit(st, ast::Minus) => {
let istr = ast_util::int_ty_to_string(st, Some(-(i as i64)));
let istr = ast_util::int_val_to_string(st, -(i as i64));
word(self.writer(),
&format!("-{}", istr))
}
ast::UnsignedIntLit(ut) => {
word(self.writer(), &ast_util::uint_ty_to_string(ut, Some(i)))
word(self.writer(), &ast_util::uint_val_to_string(ut, i))
}
ast::UnsuffixedIntLit(ast::Plus) => {
word(self.writer(), &format!("{}", i))