]> git.lizzy.rs Git - rust.git/commitdiff
Add a casting hack to make more tests pass.
authorScott Olson <scott@solson.me>
Mon, 13 Jun 2016 03:36:02 +0000 (21:36 -0600)
committerScott Olson <scott@solson.me>
Mon, 13 Jun 2016 03:36:02 +0000 (21:36 -0600)
src/interpreter/mod.rs

index bb3d15f9e182ff15d53db02eff4fe0fe2f7b2cce..f77ddae6aaa6ec8c9df9c11ab1e3752ecba94cba 100644 (file)
@@ -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)));