Skip to content

Disable MIR inlining when stubbing is enabled - #5095

Open
r-near wants to merge 2 commits into
model-checking:mainfrom
r-near:fix-stub-mir-inline
Open

r-near wants to merge 2 commits into
model-checking:mainfrom
r-near:fix-stub-mir-inline

Conversation

@r-near

@r-near r-near commented Oct 28, 2026 •

Copy link
Copy Markdown

At opt-level 2/3, rustc's MIR inliner copies a stubbed function into its callers, and FnStubPass only replaces the function's own body, so the stub was silently skipped there. This passes -Z inline-mir=no to the crate under verification whenever stubbing is enabled (including via function contracts). Dependencies skip codegen, so they don't get it; passing it to them would only force a rebuild.

Adds tests/kani/Stubbing/stub_inlined_function.rs and tests/cargo-kani/stubbing-inlined-function, which fail before this change.

Resolves #5094

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@r-near
r-near requested review from a team as code owners October 28, 2026 17:20
@github-actions github-actions Bot added Z-EndToEndBenchCI Tag a PR to run benchmark CI Z-CompilerBenchCI Tag a PR to run benchmark CI labels Oct 28, 2026
@feliperodri
feliperodri requested a balanced review from Copilot October 31, 2026 00:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change that disables MIR inlining when stubbing is enabled.

No open issues 🎉

What changed in this PR

Prevents MIR inlining from bypassing Kani function stubs at optimization levels 2 and 3, addressing the false verification results reported in #5094.

Changes:

  • Passes -Z inline-mir=no when stubbing is enabled, including through function contracts.
  • Adds an optimization-level-2 regression test checking that a stub applies through an intermediate caller.
File Description
tests/​kani/​Stubbing/​stub_inlined_function.rs Tests stub application through a caller with optimization enabled.
kani-driver/​src/​call_single_file.rs Disables MIR inlining when stubbing is enabled.

Review effort: Balanced

Dependencies skip codegen, so passing the flag to them only changed their
flags and forced a rebuild, which broke `build-cache-dirty` for
`-Z function-contracts`. Add a cargo test for the local-crate path.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-CompilerBenchCI Tag a PR to run benchmark CI Z-EndToEndBenchCI Tag a PR to run benchmark CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#[kani::stub] silently not applied to MIR-inlined calls (opt-level 2/3): false proofs

2 participants