mir: avoid double substitution

This commit avoids a natural, free-range double substitution error by
monomorphizing the projection element before getting the type.

Signed-off-by: David Wood <david@davidtw.co>
This commit is contained in:
David Wood 2020-06-22 12:53:40 +01:00
parent 05630b06fd
commit 996bc9abb5
No known key found for this signature in database
GPG key ID: 2592E76C87381FD9

View file

@ -124,8 +124,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
let base_ty = self.fx.monomorphize(&base_ty);
// ZSTs don't require any actual memory access.
let elem_ty = base_ty.projection_ty(cx.tcx(), elem).ty;
let elem_ty = self.fx.monomorphize(&elem_ty);
let elem_ty = base_ty.projection_ty(cx.tcx(), self.fx.monomorphize(&elem)).ty;
let span = self.fx.mir.local_decls[place_ref.local].source_info.span;
if cx.spanned_layout_of(elem_ty, span).is_zst() {
return;