Address review comments
This commit is contained in:
parent
d18b405faf
commit
e2ff1881b2
@ -115,12 +115,12 @@ pub fn check_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, cast: &CastCheck<'tcx>) {
|
||||
} else if t_1.sty == ty::ty_bool {
|
||||
span_err!(fcx.tcx().sess, span, E0054,
|
||||
"cannot cast as `bool`, compare with zero instead");
|
||||
} else if t_e_is_float && (t_1_is_scalar || t_1_is_c_enum) && !(
|
||||
t_1_is_integral || t_1_is_float) {
|
||||
} else if t_e_is_float && (t_1_is_scalar || t_1_is_c_enum) &&
|
||||
!(t_1_is_integral || t_1_is_float) {
|
||||
// Casts from float must go through an integer
|
||||
cast_through_integer_err(fcx, span, t_1, t_e)
|
||||
} else if t_1_is_float && (t_e_is_scalar || t_e_is_c_enum) && !(
|
||||
t_e_is_integral || t_e_is_float || t_e.sty == ty::ty_bool) {
|
||||
} else if t_1_is_float && (t_e_is_scalar || t_e_is_c_enum) &&
|
||||
!(t_e_is_integral || t_e_is_float || t_e.sty == ty::ty_bool) {
|
||||
// Casts to float must go through an integer or boolean
|
||||
cast_through_integer_err(fcx, span, t_1, t_e)
|
||||
} else if t_e_is_c_enum && t_1_is_trivial {
|
||||
|
@ -1560,13 +1560,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn type_is_fat_ptr(&self, ty: Ty<'tcx>, span: Span) -> bool {
|
||||
match ty.sty {
|
||||
ty::ty_ptr(ty::mt { ty: t, .. }) |
|
||||
ty::ty_rptr(_, ty::mt { ty: t, .. }) => {
|
||||
!self.type_is_known_to_be_sized(t, span)
|
||||
}
|
||||
_ => false
|
||||
if let Some(mt) = ty::deref(ty, true) {
|
||||
return !self.type_is_known_to_be_sized(mt.ty, span);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn register_builtin_bound(&self,
|
||||
|
@ -10,5 +10,10 @@
|
||||
|
||||
fn main() {
|
||||
let a: &[i32] = &[1, 2, 3];
|
||||
a as *const [i32] as usize; //~ ERROR cast from fat pointer
|
||||
let b: Box<[i32]> = Box::new([1, 2, 3]);
|
||||
let p = a as *const [i32];
|
||||
|
||||
a as usize; //~ ERROR cast from fat pointer
|
||||
b as usize; //~ ERROR cast from fat pointer
|
||||
p as usize; //~ ERROR cast from fat pointer
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user