Repository navigation
Give the x87_f80_raw lang item its rustc size - #5197
Conversation
nightly-2026-11-12 added the `x87_f80_raw` lang item, a struct with no
fields that rustc lays out as an 80-bit x87 float (10 bytes). Kani built
its type from the fields, so it got 0 bits, and the `x87_f80` wrapper
came out 48 bits wide instead of 128. Every transmute to or from
`x87_f80` in `core` then failed the size assertion in `transmute_to`.
Represent a field-less struct with a non-zero layout size as padding of
that size. Building such a value (`x87_f80_raw {}`, which autoharness
does through `kani::any`) also indexed operand 0 of an empty list,
because rustc reports one pseudo-field for a primitive layout; build it
from padding alone instead.
Resolves model-checking#5191
There was a problem hiding this comment.
🟡 Changes recommended
The x87_f80 layout test treats six padding bytes as initialized and preserved across a transmute, relying on behavior Rust does not guarantee; it should use MaybeUninit bytes and compare only the ten payload bytes.
1 open issue
What changed in this PR
This PR addresses #5191 by giving x87_f80_raw its rustc-defined size in Kani’s code generation, unblocking standard-library verification on the newer nightly.
Changes:
- Represent fieldless structs with nonzero layout size using padding.
- Handle empty aggregate operands without indexing rustc’s pseudo-field.
- Add x86_64 regression harnesses for
x87_f80size and transmutes.
| File | Description |
|---|---|
tests/kani/Structs/x87_f80_layout.rs |
Adds layout and transmute regression coverage. |
kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs |
Preserves rustc-defined sizes for fieldless structs. |
kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs |
Constructs padding-only aggregates without accessing missing operands. |
Review effort: Balanced
A typed copy of x87_f80 need not preserve its six padding bytes, so read the bytes back as MaybeUninit<u8> and compare the ten float bytes.
rajath-mk
left a comment
There was a problem hiding this comment.
Looks good. The x86 regression job on this head passes the new layout test (on aarch64 it's the empty harness, so I relied on CI for that), and a repr(align) unit struct still has size 0 under Kani, so the size != 0 guard keeps ordinary unit structs on the old path. Approving
Kani faffcee3 gave the field-less x87_f80_raw lang item 0 bits, so codegen of core aborted on every transmute involving x87_f80 (model-checking/kani#5191), which broke Kani List, autoharness and Kani Metrics. 53cb531 is the fix from model-checking/kani#5197 on top of faffcee3, so it stays on nightly-2026-11-12. The merged commit (b896cff) is on nightly-2026-11-18; move to a commit on Kani main at the next sync. The ESBMC job runs without Kani's reachability checks (21bd541) until ESBMC can read them: esbmc/esbmc#10875.
…#766) This is an automated PR to merge library subtree updates from 2026-10-23 (rust-lang/rust@7189d39) to 2026-11-12 (rust-lang/rust@3ef0c22) (inclusive) into main. `git merge` resulted in conflicts, which require manual resolution. Files were commited with merge conflict markers. **Do not remove or edit the following annotations:** git-subtree-dir: library git-subtree-split: 5a2d852 --- Kani is pinned to `53cb531`: the x87_f80 fix (model-checking/kani#5197) on top of `faffcee3`, kept on nightly-2026-11-12. The ESBMC job runs without Kani's reachability checks until esbmc/esbmc#10875 is resolved. --------- Signed-off-by: hashcatHitman <[email protected]> Signed-off-by: Hardik Kumar <[email protected]> Signed-off-by: Ayush Singh <[email protected]> Co-authored-by: Yash Aggarwal <[email protected]> Co-authored-by: Caleb Zulawski <[email protected]> Co-authored-by: The rustc-josh-sync Cronjob Bot <[email protected]> Co-authored-by: Jacob Pratt <[email protected]> Co-authored-by: Web4everyone32 <[email protected]> Co-authored-by: panstromek <[email protected]> Co-authored-by: Ralf Jung <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: Mend Renovate <[email protected]> Co-authored-by: Jonathan Brouwer <[email protected]> Co-authored-by: arvindkhoisnam <[email protected]> Co-authored-by: Mikolaj Wielgus <[email protected]> Co-authored-by: Trevor Gross <[email protected]> Co-authored-by: Hugo Sanz González <[email protected]> Co-authored-by: hashcatHitman <[email protected]> Co-authored-by: Yilin Chen <[email protected]> Co-authored-by: Guillaume Gomez <[email protected]> Co-authored-by: Thalia Archibald <[email protected]> Co-authored-by: bjorn3 <[email protected]> Co-authored-by: Nag <[email protected]> Co-authored-by: Max Dexheimer <[email protected]> Co-authored-by: asquared31415 <[email protected]> Co-authored-by: Chris Denton <[email protected]> Co-authored-by: The Miri Cronjob Bot <[email protected]> Co-authored-by: Frank King <[email protected]> Co-authored-by: Jules Bertholet <[email protected]> Co-authored-by: malezjaa <[email protected]> Co-authored-by: Alan Wu <[email protected]> Co-authored-by: Michael Howell <[email protected]> Co-authored-by: Voxell Paladynee <[email protected]> Co-authored-by: xtqqczze <[email protected]> Co-authored-by: Mahdi Ali-Raihan <[email protected]> Co-authored-by: Daniel Scherzer <[email protected]> Co-authored-by: Valaphee64.exe <[email protected]> Co-authored-by: Jakub Beránek <[email protected]> Co-authored-by: Folkert de Vries <[email protected]> Co-authored-by: Tim (Theemathas Chirananthavat) <[email protected]> Co-authored-by: Xing Xue <[email protected]> Co-authored-by: mejrs <[email protected]> Co-authored-by: Jana Dönszelmann <[email protected]> Co-authored-by: León Orell Valerian Liehr <[email protected]> Co-authored-by: Joy <[email protected]> Co-authored-by: Zac Harrold <[email protected]> Co-authored-by: Marius Melzer <[email protected]> Co-authored-by: krokodeyu <[email protected]> Co-authored-by: Beat Küng <[email protected]> Co-authored-by: yhx-12243 <[email protected]> Co-authored-by: waffle <[email protected]> Co-authored-by: Toni Peter <[email protected]> Co-authored-by: Zalathar <[email protected]> Co-authored-by: zannabianca1997 <[email protected]> Co-authored-by: Hardik Kumar <[email protected]> Co-authored-by: lazerg <[email protected]> Co-authored-by: Ayush Singh <[email protected]> Co-authored-by: Lewis McClelland <[email protected]> Co-authored-by: Dennis Duda <[email protected]> Co-authored-by: Nicole LeGare <[email protected]> Co-authored-by: Pavel Grigorenko <[email protected]> Co-authored-by: Shun Sakai <[email protected]> Co-authored-by: Stefan Lankes <[email protected]> Co-authored-by: Vlad Mashkautsan <[email protected]> Co-authored-by: Joseph Zhao <[email protected]> Co-authored-by: Joseph Zhao <[email protected]> Co-authored-by: gitbot <git@bot> Co-authored-by: Felipe R. Monteiro <[email protected]> Co-authored-by: Lucas C. Cordeiro <[email protected]>

Kani can't compile
coreon nightly-2026-11-12. That blocksverify-stdand the verify-rust-std toolchain sync (model-checking/verify-rust-std#766), whose Kani List, autoharness and metrics jobs all abort in codegen.The nightly added the
x87_f80_rawlang item, a struct with no fields that rustc lays out as an 80-bit x87 float (10 bytes). Kani built its type from the fields, so it had 0 bits, and thex87_f80wrapper came out 48 bits wide instead of 128. Every transmute betweenx87_f80andMaybeUninit<x87_f80>incorethen hit the size assertion intransmute_to.The fix gives a field-less struct with a non-zero layout size a single padding component of that size. A second crash showed up once the first was gone: building
x87_f80_raw {}(autoharness does this throughkani::any) indexed operand 0 of an empty list, because rustc reports one pseudo-field for a primitive layout. That value is now built from padding alone.Where I'd like input: the padding-only representation keeps the bits nondeterministic, which is right as long as Kani has no x87 float semantics. If we'd rather model it as an 80-bit float type in CBMC, that's a bigger change, and I'd do it separately.
Testing:
tests/kani/Structs/x87_f80_layout.rschecks the wrapper's size and round-trips bytes through the same transmutescoredoes. Without the fix it reproduces the panic from Codegen ICE onx87_f80(nightly-2026-11-12):transmute_tosize mismatch 128 vs 48 bits #5191.kanicompiletest suite passes (657 passed, 0 failed).kani list --with-autoharnesson verify-rust-std#766 now completes (it aborted in codegen before). The second fix has no regression test of its own: onlycorecan constructx87_f80_raw, so that path is covered byverify-stdruns.Resolves #5191
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.