Skip to content

Commit

Permalink
Use immediate_backend_type when reading from a const alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Dec 9, 2023
1 parent 2b399b5 commit b0a5801
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 b0a5801

Please sign in to comment.