mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
Clean up the binary hex lint
This commit is contained in:
parent
c0fc6a8b6b
commit
47e0bb59db
@ -21,7 +21,7 @@ use lint::{LintPass, LateLintPass};
|
|||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
|
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::{ast, attr};
|
||||||
use syntax::abi::Abi;
|
use syntax::abi::Abi;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use syntax::codemap;
|
use syntax::codemap;
|
||||||
@ -365,12 +365,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
|||||||
) {
|
) {
|
||||||
let (t, actually) = match ty {
|
let (t, actually) = match ty {
|
||||||
ty::TyInt(t) => {
|
ty::TyInt(t) => {
|
||||||
let bits = int_ty_bits(t, cx.sess().target.isize_ty);
|
let ity = attr::IntType::SignedInt(t);
|
||||||
|
let bits = layout::Integer::from_attr(cx.tcx, ity).size().bits();
|
||||||
let actually = (val << (128 - bits)) as i128 >> (128 - bits);
|
let actually = (val << (128 - bits)) as i128 >> (128 - bits);
|
||||||
(format!("{:?}", t), actually.to_string())
|
(format!("{:?}", t), actually.to_string())
|
||||||
}
|
}
|
||||||
ty::TyUint(t) => {
|
ty::TyUint(t) => {
|
||||||
let bits = uint_ty_bits(t, cx.sess().target.usize_ty);
|
let ity = attr::IntType::UnsignedInt(t);
|
||||||
|
let bits = layout::Integer::from_attr(cx.tcx, ity).size().bits();
|
||||||
let actually = (val << (128 - bits)) >> (128 - bits);
|
let actually = (val << (128 - bits)) >> (128 - bits);
|
||||||
(format!("{:?}", t), actually.to_string())
|
(format!("{:?}", t), actually.to_string())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user