Skip to content

Commit df98e6b

Browse files
committed
fix cranelift and gcc backends
1 parent abd6c9a commit df98e6b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ pub(crate) fn codegen_const_value<'tcx>(
167167
}
168168

169169
match const_val {
170+
ConstValue::ZST => unreachable!(), // we already handles ZST above
170171
ConstValue::Scalar(x) => match x {
171172
Scalar::Int(int) => {
172173
if fx.clif_type(layout.ty).is_some() {

compiler/rustc_codegen_gcc/src/common.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_codegen_ssa::traits::{
99
StaticMethods,
1010
};
1111
use rustc_middle::mir::Mutability;
12-
use rustc_middle::ty::ScalarInt;
1312
use rustc_middle::ty::layout::{TyAndLayout, LayoutOf};
1413
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
1514
use rustc_span::Symbol;
@@ -157,13 +156,13 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
157156
None
158157
}
159158

159+
fn zst_to_backend(&self, _ty: Type<'gcc>) -> RValue<'gcc> {
160+
self.const_undef(self.type_ix(0))
161+
}
162+
160163
fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) -> RValue<'gcc> {
161164
let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
162165
match cv {
163-
Scalar::Int(ScalarInt::ZST) => {
164-
assert_eq!(0, layout.size(self).bytes());
165-
self.const_undef(self.type_ix(0))
166-
}
167166
Scalar::Int(int) => {
168167
let data = int.assert_bits(layout.size(self));
169168

0 commit comments

Comments
 (0)