Skip to content

Commit 996bc9a

Browse files
committed
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>
1 parent 05630b0 commit 996bc9a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/librustc_codegen_ssa/mir/analyze.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
124124
let base_ty = self.fx.monomorphize(&base_ty);
125125

126126
// ZSTs don't require any actual memory access.
127-
let elem_ty = base_ty.projection_ty(cx.tcx(), elem).ty;
128-
let elem_ty = self.fx.monomorphize(&elem_ty);
127+
let elem_ty = base_ty.projection_ty(cx.tcx(), self.fx.monomorphize(&elem)).ty;
129128
let span = self.fx.mir.local_decls[place_ref.local].source_info.span;
130129
if cx.spanned_layout_of(elem_ty, span).is_zst() {
131130
return;

0 commit comments

Comments
 (0)