Fixes missing overflow lint for i64 #14269
The `type_overflow` lint, doesn't catch the overflow for `i64` because the overflow happens earlier in the parse phase when the `u64` as biggest possible int gets casted to `i64` , without checking the for overflows. We can't lint in the parse phase, so a refactoring of the `LitInt` type was necessary. The types `LitInt`, `LitUint` and `LitIntUnsuffixed` where merged to one type `LitInt` which stores it's value as `u64`. An additional parameter was added which indicate the signedness of the type and the sign of the value.
This commit is contained in:
@@ -37,11 +37,14 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
|
||||
ast::LitChar(c) => {
|
||||
accumulator.push_char(c);
|
||||
}
|
||||
ast::LitInt(i, _) | ast::LitIntUnsuffixed(i) => {
|
||||
ast::LitInt(i, ast::UnsignedIntLit(_)) |
|
||||
ast::LitInt(i, ast::SignedIntLit(_, ast::Plus)) |
|
||||
ast::LitInt(i, ast::UnsuffixedIntLit(ast::Plus)) => {
|
||||
accumulator.push_str(format!("{}", i).as_slice());
|
||||
}
|
||||
ast::LitUint(u, _) => {
|
||||
accumulator.push_str(format!("{}", u).as_slice());
|
||||
ast::LitInt(i, ast::SignedIntLit(_, ast::Minus)) |
|
||||
ast::LitInt(i, ast::UnsuffixedIntLit(ast::Minus)) => {
|
||||
accumulator.push_str(format!("-{}", i).as_slice());
|
||||
}
|
||||
ast::LitNil => {}
|
||||
ast::LitBool(b) => {
|
||||
|
||||
Reference in New Issue
Block a user