Skip to content

Upgrade Rust toolchain to nightly-2026-04-01 - #4734

Open
feliperodri wants to merge 3 commits into
model-checking:mainfrom
feliperodri:upgrade-toolchain-2026-04-01
Open

Upgrade Rust toolchain to nightly-2026-04-01#4734
feliperodri wants to merge 3 commits into
model-checking:mainfrom
feliperodri:upgrade-toolchain-2026-04-01

Conversation

@feliperodri

@feliperodri feliperodri commented Aug 13, 2026

Copy link
Copy Markdown
Member

Advance from nightly-2026-03-01 to nightly-2026-04-01. Several source changes are required to track rustc and rustc_public API changes.

Codegen backend interface. CodegenResults is gone: rustc now keeps the compiled modules and the crate info apart. codegen_crate receives a &CrateInfo instead of the backend building one, join_codegen returns CompiledModules, link takes the modules and the crate info separately, link_binary gained a matching parameter, and target_cpu became a required method (implemented as cranelift does, honouring -C target-cpu). The backend factory closure in kani_compiler.rs now takes only the session.

rustc_span re-exports. respan, Spanned and dummy_spanned are no longer public under rustc_span::source_map; import them from the crate root.

Allocation shim signatures. The shims changed shape twice over, and both changes broke every test that allocates — 128 of them:

  • align is now core::mem::Alignment rather than core::ptr::Alignment. Kani already maps that type to size_t for FFI so the shims link against the size_t definitions in kani_lib.c, but the detection matched on the old path only. Both paths are now accepted.
  • The pointer arguments of __rust_dealloc and __rust_realloc are now NonNull<u8> rather than *mut u8. NonNull<T> is repr(transparent) over *const T, so it holds the same address, but its goto type is a struct and would not match the pointer-typed C definitions. Foreign signatures now represent it as a pointer, via a nonnull_pointee helper in kani_middle shared with the uninitialized-memory instrumentation.

The same NonNull change reached the uninitialized-memory checks two ways, which is why -Z uninit-checks was crashing with Should only build checks for raw pointers, std::ptr::NonNull<u8> encountered: the pointee type had to be resolved through the wrapper, and the argument handed to the shadow-memory model had to be the inner pointer, obtained by projecting NonNull's single field.

Float intrinsics. fabsf16/fabsf32/fabsf64/fabsf128 were replaced by a single generic fabs<T: FloatPrimitive>; the width is now recovered from the signature so codegen keeps using the width-specific CBMC builtins, and the four unmatchable arms are removed. maxnumf32/maxnumf64 and minnumf32/minnumf64 were renamed to maximum_number_nsz_* and minimum_number_nsz_* — the same semantics f32::max/f32::min use. Tests calling these by name are updated.

Stale feature gates. unused_features now fires on gates a crate does not use, which caught five:

  • kani_macros: proc_macro_diagnostic is only needed by the #[cfg(kani_sysroot)] module, so it is declared with cfg_attr; proc_macro_span is not used at all (the span APIs in loop_contracts come from syn/proc-macro2) and is removed.
  • library/kani: layout_for_ptr is only reached by the concrete_playback paths of the kani_core memory models, so it is tied to that feature.
  • kani_core: f16/f128 appear only inside macro bodies that expand in downstream crates, which declare the gates themselves.
  • kani-compiler: more_qualified_paths, and compile-timer: exit_status_error, are both unused.

Upstream commit range: 38c0de8dcb14d42290042521be9958d37f3fa390...48cc71ee88cd0f11217eced958b9930970da998b

Resolves #4737.

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

Advance from nightly-2026-03-01 to nightly-2026-04-01. Several source
changes are required to track rustc and rustc_public API changes.

**Codegen backend interface.** `CodegenResults` is gone: rustc now keeps
the compiled modules and the crate info apart. `codegen_crate` receives a
`&CrateInfo` instead of the backend building one, `join_codegen` returns
`CompiledModules`, `link` takes the modules and the crate info separately,
`link_binary` gained a matching parameter, and `target_cpu` became a
required method, implemented as cranelift does so that `-C target-cpu` is
honoured. The backend factory closure now takes only the session.

**`rustc_span` re-exports.** `respan`, `Spanned` and `dummy_spanned` are no
longer public under `rustc_span::source_map`; import them from the root.

**Allocation shim signatures.** These changed twice over, and between them
broke every test that allocates -- 128 of them:

- `align` is now `core::mem::Alignment` rather than `core::ptr::Alignment`.
  Kani already maps that type to `size_t` for FFI so the shims link against
  the `size_t` definitions in `kani_lib.c`, but the detection matched the
  old path only.
- `__rust_dealloc` and `__rust_realloc` now take `NonNull<u8>` rather than
  `*mut u8`. `NonNull<T>` is `repr(transparent)` over `*const T`, so it
  holds the same address, but its goto type is a struct and would not match
  the pointer-typed C definitions.

The `NonNull` change reached the uninitialized-memory checks two ways,
which is why `-Z uninit-checks` crashed with `Should only build checks for
raw pointers, std::ptr::NonNull<u8> encountered`: the pointee type has to
be resolved through the wrapper, and the argument handed to the
shadow-memory model has to be the inner pointer, obtained by projecting
`NonNull`'s single field. The `nonnull_pointee` helper lives in
`kani_middle` since both the FFI signatures and the instrumentation need it.

**Float intrinsics.** `fabsf16`/`fabsf32`/`fabsf64`/`fabsf128` were replaced
by a single generic `fabs<T: FloatPrimitive>`, so the width is recovered
from the signature and codegen keeps using the width-specific CBMC
builtins; the four unmatchable arms are removed. `maxnumf32`/`maxnumf64`
and `minnumf32`/`minnumf64` became `maximum_number_nsz_*` and
`minimum_number_nsz_*`, the same semantics `f32::max`/`f32::min` use.
Tests calling these by name are updated.

**Stale feature gates.** `unused_features` now fires on gates a crate does
not use, which caught five. `proc_macro_diagnostic` is only needed by
`kani_macros`'s `#[cfg(kani_sysroot)]` module, so it is declared with
`cfg_attr`, while `proc_macro_span` is not used at all -- the span APIs in
`loop_contracts` come from `syn`/`proc-macro2`. `layout_for_ptr` is only
reached by the `concrete_playback` paths of the `kani_core` memory models,
so it is tied to that feature. `kani_core`'s `f16`/`f128` appear only inside
macro bodies that expand in downstream crates, which declare the gates
themselves. `more_qualified_paths` and `exit_status_error` are unused.

Verified locally: the `kani` suite passes 600/600, both clippy passes and
the format check are clean, and the per-package unit tests pass. The
`shadow/unsupported_num_objects` expected test counts CBMC object IDs and
my local CBMC suite is inconsistent (cbmc 6.10.0 with goto-synthesizer
6.8.0), so the remaining suites are left to CI.

Upstream range:
38c0de8dcb14d42290042521be9958d37f3fa390...48cc71ee88cd0f11217eced958b9930970da998b
@feliperodri
feliperodri requested a review from a team as a code owner August 13, 2026 22:02
@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 Aug 13, 2026
@feliperodri feliperodri added the [C] Internal Tracks some internal work. I.e.: Users should not be affected. label Aug 13, 2026
The Lean backend has its own `CodegenBackend` implementation, and it needs
the identical treatment: `CompiledModules` in place of `CodegenResults`,
`codegen_crate` taking `&CrateInfo`, `link` taking the modules and the crate
info separately, the extra `link_binary` argument, and the new required
`target_cpu`. Since rustc now builds the `CrateInfo` itself, the backend no
longer maps `tcx.sess.target.arch` into it, which leaves the
`rustc_target::spec::Arch` import unused.

Missed in the previous commit because the backend is behind the optional
`llbc` feature, so the default build never compiles it -- `llbc-regression`
caught it. Verified with `cargo build-dev -- --features cprover --features
llbc` and the `llbc` suite, 10 passed.

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

Upgrades Kani to Rust nightly 2026-04-01 and adapts compiler integrations to upstream API changes.

Changes:

  • Updates codegen backend and rustc API usage.
  • Supports revised allocation shims and uninitialized-memory instrumentation.
  • Migrates renamed float intrinsics and removes obsolete feature gates.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rust-toolchain.toml Updates the nightly toolchain.
tools/compile-timer/src/compile-timer.rs Removes an unused feature gate.
library/kani/src/lib.rs Gates layout_for_ptr by feature.
library/kani_macros/src/lib.rs Narrows proc-macro feature usage.
library/kani_core/src/lib.rs Removes unused float feature gates.
kani-compiler/src/main.rs Removes an obsolete feature gate.
kani-compiler/src/kani_compiler.rs Updates backend factory signature.
kani-compiler/src/intrinsics.rs Handles renamed generic float intrinsics.
kani-compiler/src/kani_middle/mod.rs Adds NonNull pointee resolution.
kani-compiler/src/kani_middle/intrinsics.rs Updates Spanned import.
kani-compiler/src/kani_middle/points_to/points_to_analysis.rs Updates Spanned import.
kani-compiler/src/kani_middle/transform/internal_mir.rs Updates dummy_spanned usage.
kani-compiler/src/kani_middle/transform/check_uninit/mod.rs Supports NonNull operands.
kani-compiler/src/kani_middle/transform/check_uninit/ptr_uninit/uninit_visitor.rs Projects shim pointers for instrumentation.
kani-compiler/src/codegen_cprover_gotoc/context/goto_ctx.rs Updates respan import.
kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs Migrates the goto backend interface.
kani-compiler/src/codegen_cprover_gotoc/codegen/foreign_function.rs Adapts allocation-shim FFI types.
kani-compiler/src/codegen_aeneas_llbc/compiler_interface.rs Migrates the LLBC backend interface.
tests/kani/Intrinsics/Math/fabsf16.rs Tests generic fabs for f16.
tests/kani/Intrinsics/Math/fabsf32.rs Tests generic fabs for f32.
tests/kani/Intrinsics/Math/fabsf64.rs Tests generic fabs for f64.
tests/kani/Intrinsics/Math/fabsf128.rs Tests generic fabs for f128.
tests/kani/Intrinsics/MaxNum/maxnumf32.rs Uses renamed f32 maximum intrinsic.
tests/kani/Intrinsics/MaxNum/maxnumf64.rs Uses renamed f64 maximum intrinsic.
tests/kani/Intrinsics/MinNum/minnumf32.rs Uses renamed f32 minimum intrinsic.
tests/kani/Intrinsics/MinNum/minnumf64.rs Uses renamed f64 minimum intrinsic.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread kani-compiler/src/kani_middle/mod.rs Outdated
Comment thread kani-compiler/src/intrinsics.rs
Comment thread kani-compiler/src/codegen_cprover_gotoc/codegen/foreign_function.rs
Three documentation defects from the previous commits, all valid.

`nonnull_pointee` was inserted between `readable_name`'s doc comment and
`readable_name` itself, so that comment -- which explains stripping the
local crate prefix after rust-lang/rust#149401 -- ended up documenting the
new helper, and `readable_name` was left undocumented. The helper now sits
after `readable_name`, restoring the original pairing.

`is_alignment`'s summary still claimed it checks `core::ptr::Alignment`
only, while it accepts the `mem` and `ptr` modules under both `core` and
`std`.

The user-facing intrinsic support table in
`docs/src/rust-feature-support/intrinsics.md` still advertised the removed
`fabsf32`/`fabsf64`, `maxnumf*` and `minnumf*` names. It now lists `fabs`
and the `maximum_number_nsz_*`/`minimum_number_nsz_*` names this PR matches
on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[C] Internal Tracks some internal work. I.e.: Users should not be affected. 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.

Toolchain upgrade to nightly-2026-03-03 failed

3 participants