Skip to content

Commit 3bf2011

Browse files
committed
Take care of zero-width constants. Needs a workover.
1 parent f7c7bb7 commit 3bf2011

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/librustc_trans/trans/expr.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,20 @@ pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
149149
},
150150
}
151151
}
152+
153+
// If we see a const here, that's because it evaluates to a type with zero size. We
154+
// should be able to just discard it.
155+
// FIXME: Check the type of the expression and see if it's a zero-size type instead of
156+
// this hack.
157+
if let hir::ExprPath(..) = expr.node {
158+
match bcx.def(expr.id) {
159+
Def::Const(_) | Def::AssociatedConst(_) => {
160+
return bcx;
161+
}
162+
_ => {}
163+
}
164+
}
165+
152166
// Even if we don't have a value to emit, and the expression
153167
// doesn't have any side-effects, we still have to translate the
154168
// body of any closures.

0 commit comments

Comments
 (0)