Skip to content

Upgrade Rust toolchain to nightly-2026-02-06#4655

Merged
tautschnig merged 3 commits into
model-checking:mainfrom
tautschnig:toolchain-2026-02-06-manual
Jul 23, 2026
Merged

Upgrade Rust toolchain to nightly-2026-02-06#4655
tautschnig merged 3 commits into
model-checking:mainfrom
tautschnig:toolchain-2026-02-06-manual

Conversation

@tautschnig

Copy link
Copy Markdown
Member

rust-lang/rust stopped encoding optimized MIR for ADT constructors (instance_mir uses mir_for_ctfe for them). As a result, rustc_public::Instance::body() returns None for constructors imported from other crates (its has_body check keys off is_mir_available, i.e. optimized MIR), so codegenning a constructor used as a function value (e.g. .map(Some)) panicked on instance.body().unwrap().

Reconstruct the missing constructor body the same way rustc_public's BodyBuilder would (fetch instance_mir, monomorphize, convert to stable MIR) when body() is None and the instance is a constructor; any other bodyless instance still panics.

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

Copilot AI review requested due to automatic review settings July 18, 2026 22:57
@tautschnig
tautschnig requested a review from a team as a code owner July 18, 2026 22:57
@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 Jul 18, 2026

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.

Pull request overview

Updates Kani to a newer nightly and adapts the StableMIR body retrieval path to handle Rust’s change in how ADT constructor MIR is provided, avoiding panics when constructors from external crates are used as function values.

Changes:

  • Bump Rust toolchain to nightly-2026-02-06.
  • Add a targeted fallback that reconstructs constructor bodies via internal rustc APIs when rustc_public::Instance::body() returns None.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
rust-toolchain.toml Updates the pinned nightly toolchain to nightly-2026-02-06.
kani-compiler/src/kani_middle/transform/mod.rs Reconstructs missing StableMIR bodies for ADT constructors when Instance::body() is unavailable, preventing .unwrap() panics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kani-compiler/src/kani_middle/transform/mod.rs
rust-lang/rust stopped encoding *optimized* MIR for ADT constructors
(`instance_mir` uses `mir_for_ctfe` for them). As a result,
`rustc_public::Instance::body()` returns `None` for constructors imported from
other crates (its `has_body` check keys off `is_mir_available`, i.e. optimized
MIR), so codegenning a constructor used as a function value (e.g. `.map(Some)`)
panicked on `instance.body().unwrap()`.

Reconstruct the missing constructor body the same way `rustc_public`'s
`BodyBuilder` would (fetch `instance_mir`, monomorphize, convert to stable MIR)
when `body()` is `None` and the instance is a constructor; any other bodyless
instance still panics.

A regression test is added under `tests/kani/FunctionCall/ctor_as_fn_value.rs`,
exercising cross-crate constructors (`Some`, `std::num::Wrapping`) and a local
constructor used as function values; the cross-crate harnesses panic the
compiler without this fix.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig
tautschnig force-pushed the toolchain-2026-02-06-manual branch from 5a1dc92 to d90e863 Compare July 18, 2026 23:48

@feliperodri feliperodri 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.

Tried to re-run the failed job but got:

Run actions/checkout@v6
Error: Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.

@tautschnig
tautschnig added this pull request to the merge queue Jul 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 21, 2026
@tautschnig
tautschnig enabled auto-merge July 23, 2026 18:11
@tautschnig
tautschnig added this pull request to the merge queue Jul 23, 2026
Merged via the queue into model-checking:main with commit de332bb Jul 23, 2026
34 checks passed
@tautschnig
tautschnig deleted the toolchain-2026-02-06-manual branch July 23, 2026 19:54
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.

3 participants