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:
parent
795f6ae829
commit
0dc215741b
18 changed files with 142 additions and 99 deletions
|
@ -34,7 +34,7 @@ use ast::{Ident, NormalFn, Inherited, Item, Item_, ItemStatic};
|
|||
use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl};
|
||||
use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, Lit, Lit_};
|
||||
use ast::{LitBool, LitChar, LitByte, LitBinary};
|
||||
use ast::{LitNil, LitStr, LitUint, Local, LocalLet};
|
||||
use ast::{LitNil, LitStr, LitInt, Local, LocalLet};
|
||||
use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, Matcher, MatchNonterminal};
|
||||
use ast::{MatchSeq, MatchTok, Method, MutTy, BiMul, Mutability};
|
||||
use ast::{NamedField, UnNeg, NoReturn, UnNot, P, Pat, PatEnum};
|
||||
|
@ -1889,7 +1889,7 @@ impl<'a> Parser<'a> {
|
|||
pub fn mk_lit_u32(&mut self, i: u32) -> Gc<Expr> {
|
||||
let span = &self.span;
|
||||
let lv_lit = box(GC) codemap::Spanned {
|
||||
node: LitUint(i as u64, TyU32),
|
||||
node: LitInt(i as u64, ast::UnsignedIntLit(TyU32)),
|
||||
span: *span
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue