From: Scott Olson Date: Mon, 13 Jun 2016 03:36:02 +0000 (-0600) Subject: Add a casting hack to make more tests pass. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=f06610f34cbe7be5ef8a818f2ffdd50874b248a9;p=rust.git Add a casting hack to make more tests pass. --- diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index bb3d15f9e18..f77ddae6aaa 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -1055,10 +1055,17 @@ fn eval_assignment(&mut self, lvalue: &mir::Lvalue<'tcx>, rvalue: &mir::Rvalue<' Misc => { // FIXME(solson): Wrong for almost everything. + warn!("misc cast from {:?} to {:?}", src_ty, dest_ty); let dest_size = self.type_size(dest_ty); let src_size = self.type_size(src_ty); - if dest_size == src_size { - warn!("performing fishy cast from {:?} to {:?}", src_ty, dest_ty); + + // Hack to support fat pointer -> thin pointer casts to keep tests for + // other things passing for now. + let is_fat_ptr_cast = pointee_type(src_ty).map(|ty| { + !self.type_is_sized(ty) + }).unwrap_or(false); + + if dest_size == src_size || is_fat_ptr_cast { self.memory.copy(src, dest, dest_size)?; } else { return Err(EvalError::Unimplemented(format!("can't handle cast: {:?}", rvalue)));