diff options
| author | Ralf Jung <post@ralfj.de> | 2020-03-29 15:14:49 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-04-02 22:33:47 +0200 |
| commit | 100c809386149ef2a9dcda3f79d1416bd07dbb59 (patch) | |
| tree | 269244f8ba07804854741462acf1f6c6ed4a6416 /src | |
| parent | f1ea2731335b1e6c84ebd2d4cd767626ee1073df (diff) | |
| download | rust-100c809386149ef2a9dcda3f79d1416bd07dbb59.tar.gz rust-100c809386149ef2a9dcda3f79d1416bd07dbb59.zip | |
also accept fn-ptr-type-changing assignments
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/interpret/place.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index b16c7ffbffd..5d4976c09bb 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -287,10 +287,15 @@ impl<'tcx, Tag: ::std::fmt::Debug> PlaceTy<'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 @@ where // 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, ); |
