Skip to content

Upgrade Rust toolchain to nightly-2026-01-14#4643

Open
tautschnig wants to merge 1 commit into
model-checking:mainfrom
tautschnig:toolchain-2026-01-14-manual
Open

Upgrade Rust toolchain to nightly-2026-01-14#4643
tautschnig wants to merge 1 commit into
model-checking:mainfrom
tautschnig:toolchain-2026-01-14-manual

Conversation

@tautschnig

Copy link
Copy Markdown
Member

rust-lang/rust "Explicitly export core and std macros" replaced the #[macro_use] extern crate std prelude injection with explicit macro re-exports in std::prelude::v1. Kani's library/std re-exports the real prelude via pub use std::*, so user code began resolving the original println!/assert!/etc. instead of Kani's #[macro_export] overrides. The real println! then pulled its full formatting/I/O machinery into verification, including an unbounded core::slice::memchr::memrchr loop that made symbolic execution nonterminating (this is what hung the automated upgrade).

Give Kani's std its own prelude module (shadowing the glob-re-exported one) whose v1 re-exports the std prelude and then explicitly re-exports Kani's overridden macros (assert, assert_eq, assert_ne, debug_assert{,_eq,_ne}, print, eprint, println, eprintln, unreachable, and panic via the same private-module trick std uses). Explicit imports take precedence over the globs, so only the overridden macros are replaced. The edition submodules re-export their overrides explicitly to resolve the otherwise-ambiguous v1-vs-core glob imports.

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 14, 2026 15:04
@tautschnig tautschnig requested a review from a team as a code owner July 14, 2026 15:04
@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 14, 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

This PR upgrades the pinned Rust nightly toolchain and updates Kani’s library/std to ensure Kani’s overridden macros (e.g., println!, assert!, panic!) are the ones users resolve from the prelude after Rust’s change to explicitly re-export core/std macros via std::prelude::v1.

Changes:

  • Bump the repo toolchain from nightly-2026-01-13 to nightly-2026-01-14.
  • Add a Kani-owned std::prelude module (behind not(concrete_playback)) that re-exports the real std prelude plus explicit re-exports of Kani’s macro overrides, including a panic! re-export using the “private-module” technique.

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 version.
library/std/src/lib.rs Introduces a shadowing prelude module to ensure Kani macro overrides win over std/core prelude macro exports.

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

Comment thread library/std/src/lib.rs Outdated
@tautschnig tautschnig force-pushed the toolchain-2026-01-14-manual branch from d728fc9 to f3bad50 Compare July 14, 2026 18:57
rust-lang/rust "Explicitly export core and std macros" replaced the
`#[macro_use] extern crate std` prelude injection with explicit macro re-exports
in `std::prelude::v1`. Kani's `library/std` re-exports the real prelude via
`pub use std::*`, so user code began resolving the *original*
`println!`/`assert!`/etc. instead of Kani's `#[macro_export]` overrides. The real
`println!` then pulled its full formatting/I/O machinery into verification,
including an unbounded `core::slice::memchr::memrchr` loop that made symbolic
execution nonterminating (this is what hung the automated upgrade).

Kani cannot simply re-export its overrides from `std::prelude::v1`: `assert`,
`debug_assert`, `unreachable` and `panic` are *core*-prelude macros, so a
`#![no_std]` dependency that imports the std prelude explicitly
(`extern crate std; use std::prelude::v1::*;`, e.g. `lazy_static`) would then be
ambiguous against the injected core prelude, a hard error (rust-lang/rust E0659).
rustc only downgrades that ambiguity to a warning for the *builtin* std/core
`panic`, not for a custom override.

Instead:
 * `library/std`'s prelude is kept in sync with the real one, overriding only the
   print family (`print`/`println`/`eprint`/`eprintln`), which is defined in `std`
   and has no core-prelude counterpart, so it is safe everywhere.
 * `kani-compiler` injects `#[macro_use] extern crate std as _kani_std_macros;` at
   the crate root of every crate it compiles (via `after_crate_root_parsing`),
   except when building the standard library itself or for `#![no_std]`/`#![no_core]`
   crates. `#[macro_use]` places the overrides in the higher-priority macro-use
   prelude, shadowing the std/core prelude macros crate-wide (nested modules
   included) without the glob-vs-prelude ambiguity. Dependencies are included so
   their assertions get the same instrumentation as the crate under verification;
   `#![no_std]` dependencies keep the plain core macros (Kani still intercepts the
   panics they lower to), which is what avoids the E0659 above.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig force-pushed the toolchain-2026-01-14-manual branch from f3bad50 to e85b2ff Compare July 15, 2026 08:50
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.

2 participants