Roll rustc_private toolchain to nightly-2025-01-01 - #1998
Conversation
a400780 to
c3c8eba
Compare
Generated edition 2021 code uses pointer exposure APIs removed by the new workspace compiler. Emit the equivalent exposed-provenance `as` casts, preserving the explicit usize intermediate, enum handling, mutability, and single evaluation. Keep edition 2024 generation unchanged. Add a native-C comparison that compiles and executes the generated output on the old 2021 pin, the new workspace pin, and the separate 2024 pin. Install the new compiler in CI for this forward-compatibility regression; the workspace still uses its old compiler at this point. Published crates still pass the Rust 1.70 checks. This preparation is independent of the following rustc_private compiler transition.
Select nightly-2025-01-01, rustc 1.85.0-nightly at d117b7f211835282b3b177dc64245fff0327c04c. Keep workspace edition 2021, published MSRV 1.70, and the separate generated 2021/2024 compiler pins. CI installs the new workspace compiler alongside the generated-code pins. Document the compiler roles and exact-source requirement. Include only the small let-else formatting changes required by the new rustfmt. This begins a coupled compiler port. Intermediate port commits separate review concerns; full-workspace buildability resumes at the end of the series. Validation is against the completed tree.
Update the exhaustive AST schema, generated wrappers, and AST-only consumers for the target compiler's node and token representations. Adapt shared mutable token traversal and copy the now-private walker helpers from the exact target Rust revision, with upstream attribution. Keep traversal tests here: callback ordering, standalone item roots, precise captures, token spacing/origin, copy-on-write, and VISIT_TOKENS. Later commits port the handwritten syntax and compiler-context consumers. This is part of the coupled toolchain transition.
The target nonterminal printer can reuse captured tokens after a rewrite changes their AST. Render fresh AST fragments in a print-only copy, including nested macros, while retaining baseline bare interpolation spelling and the live AST's identity and hygiene data. Port literal construction, matching, macro collapse, and rewrite printing. Use structural attribute-token equality despite non-reflexive invisible delimiters, and keep placeholder literals distinct from source strings. Keep builder/printer/attribute tests and macro compile/run regressions with this change. Baseline comparisons cover stringify, concat, token-tree forwarding, negative postfix, and format arguments. Target compile/run regressions cover these and C strings in editions 2021 and 2024. Part of the coupled toolchain transition.
Replace mirrored private Compiler/Session ownership with public compiler callbacks and fresh analysis contexts. Reload source maps at commit and interactive boundaries; preserve Cargo/direct arguments, accepted errors, autoretype failures, and unused-unsafe diagnostics. Copy resolution before HIR lowering consumes it and retain namespace and reverse-span identity checks. Use the real body parameter environment for expression-use analysis. Consume parser diagnostics before unwinding. Driver, parser, and resolution regressions compile and execute rewritten 2021/2024 programs, including repeated transforms and external modules. Part of the coupled toolchain transition.
Preserve function-pointer headers, binders, pattern types, opaque type environments, and definition remapping across the changed type APIs. Reconstruct nested unsafe binders without losing lifetime binding or source syntax, with compile-checked reflected aliases. Opt refactor snapshots into the workspace compiler because their AST syntax comes from that compiler. Generated-code tool routing retains its existing defaults and pins. Review the type-ascription snapshot changes with this implementation. Part of the coupled toolchain transition.
Port the remaining ownership and transformation consumers to the target AST/HIR/MIR APIs. Preserve pointer permissions and account for scalar alignment/offset queries newly emitted around raw pointer operations. Retain the existing transformation algorithms and assertions. Keep the two local overflow-lint allowances with their abstract-expression fixtures; the new compiler rejects those inputs before the transformation without them. Final validation retains all 29 shell cases and all 46 refactor snapshots. Part of the coupled toolchain transition.
Adapt built-MIR pointer operations, operands, callbacks, and event metadata. Retain mandatory post-borrowck coercion cleanup and validate instrumented normal, unwind, and compiler-failure paths in all four supported editions. Review PDG snapshots with the MIR port: each profile retains all 80 graph write-permission sets; three identity pointer casts explain 755 to 758 nodes. Other deltas are compiler display and numbering changes. Rebuild the instrumented fixture package/profile before snapshots because Cargo does not fingerprint RUSTC_WRAPPER contents. Keep runtime regressions and snapshot freshness checks with this implementation. Part of the coupled toolchain transition.
Port analyzer type/dataflow consumers and reconstruct the target's MIR lowering for slice metadata, indexing, bounds checks, and arithmetic. Preserve pointer permissions, implicit Pin reborrows, and rewrite origins. Represent explicit tail-call metadata without claiming codegen support. Add 2021/2024 rewrite/compile/run coverage and focused Pin/tail-call cases. This completes the compiler transition. The final tree is identical to the previously reviewed and validated integrated migration: 270 Linux workspace tests pass with every one of the 234 baseline passes retained, plus the same existing Miri skip. Translator, shell, real-project, MSRV, and standalone-tool results are recorded in the PR.
c3c8eba to
c309c77
Compare
Code review: toolchain roll to
|
The literal evaluator truncated usize/isize through 16-bit types, while cast destinations used host pointer widths. Use the compilation target layout for both. Verify 16/32/64-bit signed and unsigned conversions, float saturation versus integer truncation, and real suffix rewrites in both editions. Preserve narrowing casts and signed-minimum runtime values.
Restore the historical Rust 2021 default when no edition is supplied, preserving explicit and Cargo-derived editions. Store captured unused-unsafe spans in a set. Add actual Cargo warning-flag coverage and strengthen the accepted-error command sequence; exact old/new executable comparisons confirm that lint suppression and accepted preexisting errors are intentional baseline behavior.
Share one lazily created parse session throughout each print operation and materialize attribute comparison tokens once per attribute. Consolidate equivalent trait/impl visitor branches while retaining their context-specific guards. Extend attribute duplicate coverage and compile/run associated-item macro rewrites in both editions against the exact baseline output shape.
Leave per-pass MIR validation under the caller's control. The pinned compiler unconditionally validates the transition to Runtime(Optimized), including at MIR optimization level zero. Validation therefore occurs later than the old private per-body check and does not promise eager final checks for unused or check-only bodies. Exercise normal and unwind paths with default, explicit yes, and explicit no settings across four editions.
Add a typed-let rewrite node with separate annotation and initializer children, preserving Pin coercions and substitution through compile/run coverage. Limit dead-code expectations to Debug-only fields, reuse the existing DefId sorting helper, and label unsupported diagnostic rendering consistently without claiming recursive labels are printed.
04880be to
bb22a94
Compare
Review follow-up: all 15 findings in Claude's review have been evaluated. Eleven led to fixes in five focused commits; four were set aside with baseline evidence or scope reasons below. The final local release build, 275 workspace tests (same existing Miri skip), 29 shell cases, and json-c/Lua translation/refactoring/build/runtime stages pass. Main CI and nine-project integration passed before these follow-ups; fresh runs are main CI and integration. The final follow-up Fable 5.1 assessment found no functional regression in the inspected diff; its full-test and documentation conditions are satisfied. The fresh GitHub runs are still in progress.
The workspace nightly is old enough that its
rustc_privatetools cannot process Rust 2024. This rolls the workspace to nightly-2025-01-01, verified as rustc 1.85.0-nightly (d117b7f211835282b3b177dc64245fff0327c04c), and ports refactoring, analysis, PDG, and instrumentation together. The required rustfmt, rustc-dev, rust-src, Miri, and rust-analyzer components are available.The workspace remains edition 2021, and published-crate MSRVs remain 1.70. Generated-code pins remain
nightly-2023-04-15for edition 2021 andnightly-2026-03-03for edition 2024. The latter uses the newerVaListAPI; replacing it with the workspace pin would break variadics. Standalone tools retain their stable toolchain.One generated-code adaptation is necessary for the real refactor workflow: edition 2021 integer/pointer conversions use equivalent exposed-provenance
ascasts instead of the removedexpose_addr/from_exposed_addrAPIs. The explicitusizeintermediate, enum handling, mutability, and single evaluation are preserved. Both exact compiler implementations define the old/new APIs in terms of these casts. A native-C comparison compiles and executes the generated program on both relevant 2021 compilers and the separate 2024 pin.The original migration has nine focused commits in the reading order below, followed by five review-fix commits. Pointer compatibility is an independent preparation. The subsequent compiler-port commits are interdependent: intermediate commits do not build the full workspace, and the completed series is the buildable, validated landing unit. Tests and snapshot changes travel with the implementation they validate. Master's CI provisioning fix is included in the base. The follow-up commits preserve the original reading order and make the review changes independently inspectable.
The follow-up commits are:
usize/isizeliteral truncation and host-width cast evaluation; test 16/32/64-bit values and real rewrites in both editions.Feedback set aside and qualifications
-Awarnings, and both remove only redundant blocks under--force-warn unused_unsafe. Added coverage; preserved suppression._: Pat and UnsafeBinder have nameable Rust forms, unlike closures/coroutines. The refactor API handles Rust beyond direct C output; erasing these constructors would break the existing nested-binder, pattern and definition-mapping tests.65536usize as u16before equality comparison. The preexisting signed-minimum case remains conservatively unsimplified; its negative runtime value is tested.No dependency roll or workspace edition conversion is included.
Validation used Linux x86_64, an LLVM 18 AST exporter, an isolated baseline archive at
e1e5bf257863107c54e9f42b345c2aeccd925458, exact old/target compiler source checkouts, and separate build directories. Workspace Cargo build/nextest commands used--lockedand denied warnings.tests/unitno_std, Rust 1.70The rebased main CI passed every configured job, including Ubuntu Clang 15/18, macOS Clang 17/22, all four standalone tools, and postprocess. The rebased nine-project integration workflow also passed both Clang jobs. The latest five corrective commits have completed local validation and are rerunning both workflows.
Each broader integration job retained nine transpiles, eight configured refactors, and the associated build/runtime and cache-only postprocess stages. Postprocess CI exercised cached responses and uncached-work handling; each Clang job applied 50 cached json-c comment updates, while Lua/Python2 skipped uncached work. Downstream builds and runtime checks passed. No live-LLM execution is claimed.
The 41 new tests are included in the 275 count; five were added for the GitHub review. Refactor and analyzer regressions compile and execute edition 2021/2024 outputs; instrumentation covers normal and unwind paths across editions 2015/2018/2021/2024 at minimum MIR optimization, and verifies that invalid edition-2024 input fails without overwriting metadata. Pin adjustment coverage compiles/runs the emitted rewrite. The explicit-tail-call regression checks metadata only because this compiler cannot codegen that feature.
Snapshot review: each PDG profile retains all 80 graph write-permission sets. Each profile’s node count changes from 755 to 758 because the target retains three identity pointer casts in
pointers::main,test_arg, andtest_arg_rec; comparison contracts only those source-justified copy nodes. Other differences are compiler printing and MIR numbering. The PDG harness now rebuilds the primary fixture package/profile so changed instrumenter contents cannot reuse staleRUSTC_WRAPPERartifacts. Refactor snapshot changes are the compiler's new type-ascription spelling and two local overflow-lint allowances in an existing arithmetic fixture. Original transformation assertions remain, and all 46 refactor snapshot tests pass.Core reproduction commands
Use Python 3.12+ with
scripts/requirements.txt, separate baseline/candidateCARGO_TARGET_DIRvalues, and the corresponding checkout/compiler:Postprocess: run
uv syncanduv run pytest -v -rainc2rust-postprocess, with built split/merge tools on PATH and the testedc2rustbinary available attarget/release/c2rust(the fixture’s expected path).Previous migration discussions and follow-up fixes were reviewed, including #1328, #1614, #1904/#1913, and the span-collision fix #1967. API adaptations were checked against the exact target compiler, with the old implementation used for behavioral comparisons.
Adversarial review: Opus 5 subsystem reviews identified issues addressed with parser diagnostic/recovery fixes, Pin reborrow preservation, structural attribute-token equality, and additional behavioral checks. Fable 5.1 completed the final semantic and reviewability assessment on the verified exact model and found no blocking defect. Its remaining evidence questions were checked against the exact printer source and old/new executable diagnostics; accepted-error warnings, exit behavior, and output matched baseline, and resolver state is copied before HIR queries consume it.
Macro printing renders the updated AST while preserving baseline bare-fragment spelling. Exact old-binary comparisons and focused regressions compile and execute five discriminating token-consumer cases in both editions, including
stringify!,concat!, arbitrary token-tree forwarding, and negative postfix expressions. Preexisting text-serialization limits remain explicit. All review findings were resolved through source checks or behavioral evidence; the final full validation above was repeated after the last code correction.Limits: live-LLM postprocessing was not exercised. The existing PDG Miri test stays skipped. The already-excluded
related_declstest still fails on a missingOTHER_CONSTANT; legacy C cross-checks fail importing removed runner helpers, and Rust cross-checks cannot build their currently resolved dependencies on either compiler (old Cargo edition parsing versus target MSRV). These are baseline limitations, not passing coverage. Existing unsupported refactor cases were not disabled or relabeled. The already-broken range-loop command's module traversal remains a deferred performance concern. MIR validation uses the compiler's mandatory final Runtime(Optimized) check instead of the old immediate private body validator. This is later in the pipeline and does not promise eager final validation for check-only or unrequested bodies; optional per-pass checking honors the caller's flags. The instrumentation README documents--rustflags=-Zvalidate-mir=yesfor additional eager and per-pass checks.