提交 100c8093 编写于 作者: R Ralf Jung

also accept fn-ptr-type-changing assignments

上级 f1ea2731
......@@ -287,10 +287,15 @@ pub fn assert_mem_place(self) -> MPlaceTy<'tcx, Tag> {
fn mir_assign_valid_types<'tcx>(src: Ty<'tcx>, dest: Ty<'tcx>) -> bool {
src == dest
|| match (&src.kind, &dest.kind) {
// After MIR optimizations, there can be assignments that change reference mutability.
(ty::Ref(_, src_pointee, _), ty::Ref(_, dest_pointee, _)) => {
// After optimizations, there can be assignments that change reference mutability.
// This does not affect reference layout, so that is fine.
src_pointee == dest_pointee
}
(ty::FnPtr(_), ty::FnPtr(_)) => {
// All function pointers have equal layout, and thus can be assigned.
true
}
_ => false,
}
}
......@@ -882,7 +887,7 @@ fn copy_op_no_validate(
// actually "transmute" `&mut T` to `&T` in an assignment without a cast.
assert!(
mir_assign_valid_types(src.layout.ty, dest.layout.ty),
"type mismatch when copying!\nsrc: {:?}, dest: {:?}",
"type mismatch when copying!\nsrc: {:?},\ndest: {:?}",
src.layout.ty,
dest.layout.ty,
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册