Skip to content

Commit 052651d

Browse files
committed
fix cranelift and gcc backends
1 parent a422b42 commit 052651d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: compiler/rustc_codegen_cranelift/src/constant.rs

+1
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() {

Diff for: compiler/rustc_codegen_gcc/src/common.rs

+4-5
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_target::abi::{self, HasDataLayout, Pointer, Size};
@@ -159,13 +158,13 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
159158
None
160159
}
161160

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

0 commit comments

Comments
 (0)