Repository navigation
Unflatten use statements in HIR - #161349
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Unflatten `use` statements in HIR
This comment has been minimized.
This comment has been minimized.
|
💔 Test for bb18a8a failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
|
The CI failure makes no sense, the only way that assert is reachable is by there being UB somewhere afaict: rust/compiler/rustc_metadata/src/rmeta/decoder.rs Lines 1447 to 1452 in b588ef3 Also I can't reproduce locally 😨 |
|
The backtrace doesn't make sense either: The assert is in And rust/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs Lines 138 to 163 in f7d782a |
probably got inlined. but the assert message says it's in a different line
I freshly rebased, so I assumed it should be fine, very odd |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Unflatten `use` statements in HIR
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (00e1020): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.0%, secondary 3.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -5.9%, secondary 3.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 470.08s -> 468.116s (-0.42%) |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing f7575a9 (parent) -> 0d38a84 (this PR) Test differencesShow 76 test diffs76 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 0d38a842626a6e3b70e2c1efd76a8f22d2556d73 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (0d38a84): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.9%, secondary 5.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.8%, secondary 2.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.636s -> 491.128s (0.10%) |
…-obk Use get to avoid ICE on unresolved imports Fixes rust-lang#163294 After rust-lang#161349, unresolved imports may not have `import_res`.
…-obk Use get to avoid ICE on unresolved imports Fixes rust-lang#163294 After rust-lang#161349, unresolved imports may not have `import_res`.
|
perf triage: The results are fairly mixed, not clearly an improvement or regression. This was measured before merge with similar results, so I assume the impact is considered as justified. This is an architectural cleanup that unblocks other improvements, I think it makes sense to accept. @rustbot label: +perf-regression-triaged |
Brings the pinned nightly from nightly-2026-09-25 to nightly-2026-10-11. The automated update has been failing since 09-26 (model-checking#4935). The range is about 1,500 rustc commits, but only a handful of changes affect Kani. One of them changes behaviour quietly, and it is the part worth reviewing. **The one that matters: `use` lists in HIR (rust-lang/rust#161349).** rustc used to lower `use a::{b, c};` into separate items, `use a::b;` and `use a::c;`. It now keeps a single item holding a tree of imports. Kani's path resolver (`kani_middle/resolve.rs`), which resolves the paths in `#[kani::stub]`, contracts and related attributes, found imported names by scanning those per-name items. Updating only the pattern would have compiled, but every name imported through a `{...}` list would have stopped resolving. `tests/kani/FunctionContracts/cross_module_multiple_impls.rs` would have caught it, because it imports its contract targets with `use crate::ty::{D, S};`. The resolver now walks each `use` tree at every level, looking for the name and collecting globs, with the same precedence as before: a named import wins over globs. The new `tests/kani/Stubbing/resolve_use_nested.rs` stubs through a list, a rename inside a list, a glob inside a list, and a list nested in a list. It passes on nightly-2026-09-25 as well, and on the new toolchain it fails with `failed to resolve` for four of its seven stubs if the walk doesn't recurse. **Mechanical API updates:** - `rustc_hir` no longer re-exports the attribute crate (rust-lang/rust#163250): `Attribute`, `AttrArgs` and `LangItem` now come from `rustc_attr_ir`. - `rustc_driver::run_compiler` is now `compiler_entrypoint` (rust-lang/rust#163647). - `mir::Terminator::attributes` is now `loop_hint_attrs`. It holds `#[unroll]` hints, which Kani-built terminators don't carry. - The `type_id` intrinsic moved to `core::intrinsics::reflection`. I also fixed the `needs_drop` panic message, which wrongly named `type_id`. - In nightly-2026-10-11, `loop_hint_attrs` moved again, from `Terminator` into `TerminatorKind::Goto` (rust-lang/rust#163931). - `rustc_abi::Float` gained `PpcF128` (rust-lang/rust#162156), PowerPC's double-double `long double`. It only exists on PowerPC targets, which Kani doesn't support, so it is reported as unsupported, like the existing `F16B` case. **Test updates.** Importing `copy`, `copy_nonoverlapping` and `write_bytes` through the accidentally stabilized `core::intrinsics` path is now a deny-by-default lint (rust-lang/rust#163160). Fifteen tests did that. They check Kani's model of the intrinsics themselves, and the `core::ptr` versions add extra debug assertions on top, so the tests now opt in to `core_intrinsics` instead of switching to `ptr`. Their expected output is unchanged. **Test updates, continued.** rustc's diagnostic for `ui/ice-size-overflow/large_array.rs` now also prints the enclosing `SizedTypeProperties` trait line, so its expected output gains two lines. Kani still reports the same E0080 there, without crashing. **Testing.** I ran `scripts/kani-regression.sh` and `scripts/kani-llbc-regression.sh` locally on nightly-2026-10-11 (Linux x86_64, CBMC 6.11.0), with `main` merged in, plus fmt and the three clippy gates (workspace, `--cfg=kani_sysroot`, `--features llbc`). Every suite passes. Charon builds unchanged. Locally I cap CBMC at 6 GB, which makes `push_slow.rs` and `cell_stub.rs` run out of memory on `main` as well; uncapped, both pass here. I also checked the other `rustc_public` changes in the range: `PassMode::IndirectUnsized` (Kani only compares against `PassMode::Ignore`) and a docs-only pointee-size change. Neither affects Kani. The earlier CI failures on this PR were the `zerocopy` 0.8.60 break (model-checking#4988), which zerocopy fixed in 0.8.61; the rerun on the previous head passed on Linux and macOS-14. Resolves model-checking#4935
View all comments
The HIR and AST representations of use statements are now mirrored, instead of having the HIR flatten the AST representation and duplicating early parts of nested paths:
used to get flattened in HIR to
which duplicated the
a::bpart several times (and many more if you have more nesting).This alone is fine, it made some parts of the compiler simpler and some parts harder, but it also meant we were generating more items (which are also owners) and had to duplicate resolver information across the flattened items. All that is gone with this PR.
This PR is the minimal version we can land, but there are obvious further avenues for cleanups and improvements. I did some refactorings in rustdoc, but I think the import logic can generally be improved by not handling imports together with other items and instead having them in separate tables.
Similarly clippy can probably benefit from a
check_use_treemethod onLateLintPass, but they often need to track separate information anyway, so it may be better to just always manually recurse.should unblock #159760
see related discussion on #t-compiler > partial_res_map vs per-owner tables @ 💬
part of rust-lang/goals#620