Skip to content

Commit d83d8be

Browse files
authored
Rollup merge of #71747 - spastorino:safety-scheme-around-consts-cleanup, r=oli-obk
Remove deadcode in eval_mir_constant_to_operand r? @oli-obk @RalfJung
2 parents 5401353 + 8bdf988 commit d83d8be

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/librustc_codegen_ssa/mir/constant.rs

+3-19
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1616
bx: &mut Bx,
1717
constant: &mir::Constant<'tcx>,
1818
) -> Result<OperandRef<'tcx, Bx::Value>, ErrorHandled> {
19-
match constant.literal.val {
20-
// Special case unevaluated statics, because statics have an identity and thus should
21-
// use `get_static` to get at their id.
22-
// FIXME(oli-obk): can we unify this somehow, maybe by making const eval of statics
23-
// always produce `&STATIC`. This may also simplify how const eval works with statics.
24-
ty::ConstKind::Unevaluated(def_id, substs, None) if self.cx.tcx().is_static(def_id) => {
25-
assert!(substs.is_empty(), "we don't support generic statics yet");
26-
let static_ = bx.get_static(def_id);
27-
// we treat operands referring to statics as if they were `&STATIC` instead
28-
let ptr_ty = self.cx.tcx().mk_mut_ptr(self.monomorphize(&constant.literal.ty));
29-
let layout = bx.layout_of(ptr_ty);
30-
Ok(OperandRef::from_immediate_or_packed_pair(bx, static_, layout))
31-
}
32-
_ => {
33-
let val = self.eval_mir_constant(constant)?;
34-
let ty = self.monomorphize(&constant.literal.ty);
35-
Ok(OperandRef::from_const(bx, val, ty))
36-
}
37-
}
19+
let val = self.eval_mir_constant(constant)?;
20+
let ty = self.monomorphize(&constant.literal.ty);
21+
Ok(OperandRef::from_const(bx, val, ty))
3822
}
3923

4024
pub fn eval_mir_constant(

0 commit comments

Comments
 (0)