Skip to content

Commit

Permalink
Auto merge of #118791 - saethlin:use-immediate-type, r=nikic
Browse files Browse the repository at this point in the history
Use immediate_backend_type when reading from a const alloc

Fixes #118047

r? `@nikic`
  • Loading branch information
bors committed Dec 10, 2023
2 parents b906831 + b0a5801 commit 7e452c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
Abi::Scalar(s @ abi::Scalar::Initialized { .. }) => {
let size = s.size(bx);
assert_eq!(size, layout.size, "abi::Scalar size does not match layout size");
let val = read_scalar(offset, size, s, bx.backend_type(layout));
let val = read_scalar(offset, size, s, bx.immediate_backend_type(layout));
OperandRef { val: OperandValue::Immediate(val), layout }
}
Abi::ScalarPair(
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/codegen/const-bool-bitcast.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This is a regression test for https://github.com/rust-lang/rust/issues/118047
// build-pass
// compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+DataflowConstProp

#![crate_type = "lib"]

pub struct State {
inner: bool
}

pub fn make() -> State {
State {
inner: true
}
}

0 comments on commit 7e452c1

Please sign in to comment.