]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #70139 - RalfJung:delay, r=eddyb
authorMazdak Farrokhzad <twingoow@gmail.com>
Sat, 21 Mar 2020 04:33:23 +0000 (05:33 +0100)
committerGitHub <noreply@github.com>
Sat, 21 Mar 2020 04:33:23 +0000 (05:33 +0100)
add delay_span_bug to TransmuteSizeDiff, just to be sure

See https://github.com/rust-lang/rust/pull/69839#discussion_r394858464.

r? @eddyb

1  2 
src/librustc_mir/interpret/place.rs

index 5313446c253c848e2864011b352cbfa180c238e4,3d40b39f61c9c9b5408cd24171d46c431745135f..400a9192682070f6e0ed04d1bd8030a95a0c600b
@@@ -410,6 -410,14 +410,6 @@@ wher
                  stride * field
              }
              layout::FieldPlacement::Union(count) => {
 -                // This is a narrow bug-fix for rust-lang/rust#69191: if we are
 -                // trying to access absent field of uninhabited variant, then
 -                // signal UB (but don't ICE the compiler).
 -                // FIXME temporary hack to work around incoherence between
 -                // layout computation and MIR building
 -                if field >= count as u64 && base.layout.abi == layout::Abi::Uninhabited {
 -                    throw_ub!(Unreachable);
 -                }
                  assert!(
                      field < count as u64,
                      "Tried to access field {} of union {:#?} with {} fields",
                          // bail out.
                          None => Place::null(&*self),
                      },
 -                    layout: self.layout_of(self.subst_from_frame_and_normalize_erasing_regions(
 -                        self.frame().body.return_ty(),
 -                    ))?,
 +                    layout: self.layout_of(
 +                        self.subst_from_current_frame_and_normalize_erasing_regions(
 +                            self.frame().body.return_ty(),
 +                        ),
 +                    )?,
                  }
              }
              local => PlaceTy {
              // most likey we *are* running `typeck` right now. Investigate whether we can bail out
              // on `typeck_tables().has_errors` at all const eval entry points.
              debug!("Size mismatch when transmuting!\nsrc: {:#?}\ndest: {:#?}", src, dest);
+             self.tcx.sess.delay_span_bug(
+                 self.tcx.span,
+                 "size-changing transmute, should have been caught by transmute checking",
+             );
              throw_inval!(TransmuteSizeDiff(src.layout.ty, dest.layout.ty));
          }
          // Unsized copies rely on interpreting `src.meta` with `dest.layout`, we want