Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use immediate_backend_type when reading from a const alloc #118791

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading