Fix invalid_upcast_comparisons lint for same size sign casts
This commit is contained in:
@@ -9,6 +9,7 @@ use rustc::traits::Reveal;
|
||||
use rustc::traits;
|
||||
use rustc::ty::subst::Subst;
|
||||
use rustc::ty;
|
||||
use rustc::ty::layout::TargetDataLayout;
|
||||
use rustc_errors;
|
||||
use std::borrow::Cow;
|
||||
use std::env;
|
||||
@@ -972,3 +973,9 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> {
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn type_size<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>) -> Option<u64> {
|
||||
cx.tcx.infer_ctxt((), Reveal::All).enter(|infcx|
|
||||
ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes())
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user