Fix name() functions for local defs in rustc_public - #149401
Conversation
This comment has been minimized.
This comment has been minimized.
|
It looks like I need to do some debugging. It's not clear to me why this change affected these tests. I.e., why:
It seems to only affect EDIT: |
|
You removed |
Thanks @oli-obk. So how should I use |
7792b9a to
ec1f5e3
Compare
|
Beautiful. @oli-obk it worked like a charm. I changed the pretty printer to use trimmed_name to make it less verbose. Thanks! |
|
Seems like this PR also fixes rust-lang/rustc_public#41? |
Good question. I haven't tried it yet |
| // WARNING: This is highly experimental output it's intended for rustc_public developers only. | ||
| // If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. | ||
| fn operands(_1: u8) -> () { | ||
| fn operands::operands(_1: u8) -> () { |
There was a problem hiding this comment.
It's slightly odd, that the body item gets a full path but things inside the body are local. wfm, just a small oddity
There was a problem hiding this comment.
Indeed. I probably missed something. Let me check
ec1f5e3 to
e77f9fe
Compare
This comment has been minimized.
This comment has been minimized.
e77f9fe to
a4186d8
Compare
This comment has been minimized.
This comment has been minimized.
The `name()` function specifies that it returns absolute path of items, however it wasn't including the crate name for local items. This change fixes that. This was reported here: rust-lang/rustc_public#109
a4186d8 to
bb2bfc3
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
I'm far from an expert on names, but the code change here looks non-scary to me, and the (admittedly not nearly all) tests I skimmed seemed like the output update was reasonable, so sure! @bors r+ |
Fix `name()` functions for local defs in rustc_public This change fixes the behavior of the `name()` function for `CrateDef` and `Instance` which should return absolute path of items. For local items, the crate name was missing. This resolves: rust-lang/rustc_public#109
Rollup of 5 pull requests Successful merges: - #146826 (Implement `Allocator` for `&mut A` where `A: Allocator + ?Sized`) - #148487 (add Option::into_flat_iter) - #148814 (stabilize `array_windows`) - #149401 (Fix `name()` functions for local defs in rustc_public) - #149683 (Fix armv8r-none-eabihf tier) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #149401 - celinval:smir-109-name, r=scottmcm Fix `name()` functions for local defs in rustc_public This change fixes the behavior of the `name()` function for `CrateDef` and `Instance` which should return absolute path of items. For local items, the crate name was missing. This resolves: rust-lang/rustc_public#109
Rollup of 5 pull requests Successful merges: - rust-lang/rust#146826 (Implement `Allocator` for `&mut A` where `A: Allocator + ?Sized`) - rust-lang/rust#148487 (add Option::into_flat_iter) - rust-lang/rust#148814 (stabilize `array_windows`) - rust-lang/rust#149401 (Fix `name()` functions for local defs in rustc_public) - rust-lang/rust#149683 (Fix armv8r-none-eabihf tier) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 5 pull requests Successful merges: - rust-lang/rust#146826 (Implement `Allocator` for `&mut A` where `A: Allocator + ?Sized`) - rust-lang/rust#148487 (add Option::into_flat_iter) - rust-lang/rust#148814 (stabilize `array_windows`) - rust-lang/rust#149401 (Fix `name()` functions for local defs in rustc_public) - rust-lang/rust#149683 (Fix armv8r-none-eabihf tier) r? `@ghost` `@rustbot` modify labels: rollup
Fix `name()` functions for local defs in rustc_public This change fixes the behavior of the `name()` function for `CrateDef` and `Instance` which should return absolute path of items. For local items, the crate name was missing. This resolves: rust-lang/rustc_public#109
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#146826 (Implement `Allocator` for `&mut A` where `A: Allocator + ?Sized`) - rust-lang#148487 (add Option::into_flat_iter) - rust-lang#148814 (stabilize `array_windows`) - rust-lang#149401 (Fix `name()` functions for local defs in rustc_public) - rust-lang#149683 (Fix armv8r-none-eabihf tier) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 5 pull requests Successful merges: - rust-lang/rust#146826 (Implement `Allocator` for `&mut A` where `A: Allocator + ?Sized`) - rust-lang/rust#148487 (add Option::into_flat_iter) - rust-lang/rust#148814 (stabilize `array_windows`) - rust-lang/rust#149401 (Fix `name()` functions for local defs in rustc_public) - rust-lang/rust#149683 (Fix armv8r-none-eabihf tier) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 5 pull requests Successful merges: - rust-lang/rust#146826 (Implement `Allocator` for `&mut A` where `A: Allocator + ?Sized`) - rust-lang/rust#148487 (add Option::into_flat_iter) - rust-lang/rust#148814 (stabilize `array_windows`) - rust-lang/rust#149401 (Fix `name()` functions for local defs in rustc_public) - rust-lang/rust#149683 (Fix armv8r-none-eabihf tier) r? `@ghost` `@rustbot` modify labels: rollup
rust-lang/rust#149401 fixed rustc_public's `Instance::name()` (and `CrateItem::name()`) to return the true absolute path, which now includes the crate name for *local* items too (e.g. `my_crate::my_fn` instead of `my_fn`, and `<my_crate::T as my_crate::Tr>::m` instead of `<T as Tr>::m`). Kani feeds these names into user-facing output ("Checking harness ...", "Verification failed for - ...", stubbing diagnostics) and into CBMC symbol pretty-names ("in function ..."), so the bump to nightly-2025-12-16 made ~160 `expected` tests fail on the newly crate-qualified names. Add `strip_local_crate_prefix` (and the `readable_name` wrapper) in kani_middle, which removes the local crate name at each path-component *qualifier* position (start, or after a delimiter such as `<`, `,`, ` `), while preserving continuation segments after `::` so a module/item that shares the crate's name (e.g. crate `main` with `fn main`) is not over-stripped. Non-local paths (`std::...`) are unaffected. Apply it at the harness pretty-name, function/static symbol pretty-name, current-function readable name, and the two stubbing diagnostics. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
The contract-recursion tests (e.g. generic_infinity_recursion, gcd_rec_simple_pass) regressed on nightly-2025-12-16: the recursive-call precondition was spuriously falsifiable. Root cause is the same rust-lang/rust#149401 name change: `find_recursion_tracker` builds the `--nondet-static-exclude` value from `static_item.name()`, which is now crate-qualified (`t::foo::{closure#0}::REENTRY`). CBMC matches that value against the static's crate-relative pretty name, so the qualified value no longer matches, `REENTRY` is not excluded from `--nondet-static`, and the recursion tracker is havocked to a nondet value. With `REENTRY` nondet the top-level contract call can take the REPLACE path (which *asserts* the precondition) instead of the CHECK path (which *assumes* it), so the precondition fails on a nondet input. Strip the local crate prefix here too (matching `readable_name`), restoring the match. Verified: the full `expected` suite is green again. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Extend the rust-lang/rust#149401 crate-prefix stripping (`strip_local_crate_prefix` / `readable_name`) to the stubbing validation error messages that still emitted crate-qualified item names, which broke the `ui` stubbing tests: the arity- and generic-parameter-mismatch errors, the trait-mismatch ("cannot be stubbed by") error, the "does not have a body" resolution notes, and the "stub verified target ... does not have a corresponding proof_for_contract harness" error. The `ui` suite is green again (144 passed, 0 failed). Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Three follow-ups from the nightly-2025-12-31 bump surfaced by CI: - clippy `result_large_err` on `ensure_non_empty_span`: the `Err` type is rustc's `SpanSnippetError`, which grew and now trips the lint. `#[allow]` it (we can't shrink an upstream type). - LLBC backend (`--features llbc`, not built in the default job): its `translate_operand` needs an arm for the new `Operand::RuntimeChecks` (rust-lang/rust#148766); left as `todo!()` like the backend's other unmodeled cases. - The stub-cycle error ("Stub configuration for harness `..` has a cycle") also embedded a crate-qualified harness name (rust-lang/rust#149401); strip it, fixing cargo-kani/stubbing-double-extern-path. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
rust-lang/rust#149401 made `name()` crate-qualify local items, which broke the autoharness and `list` features: - metadata.rs: the automatic-contract-harness lookup matched the (now crate-relative) harness `target_fn` against the fully-qualified `ContractedFunction.function`, panicking on the `.unwrap()`. Store all contract/harness names crate-relative so display and lookup are consistent. - codegen_units.rs: strip the crate prefix from the autoharness `chosen` and `skipped` function names (the `Selected Function` list column), and from the autoharness filter name, which #149401 had made doubly crate-qualified (`crate::crate::fn`). Fixes the script-based-pre autoharness/list/autoderive regression tests. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Upgrade the toolchain to `nightly-2025-12-31` and adapt Kani to the corresponding `rustc`/`rustc_public` changes: - **Crate-qualified names** (rust-lang/rust#149401): `name()` now qualifies local items with the crate name. Add a `strip_local_crate_prefix` helper and keep harness/function/static pretty names, the recursion-tracker `--nondet-static-exclude`, stubbing diagnostics, and the autoharness/`list` output crate-relative; fix the automatic contract-harness lookup accordingly. - **MIR runtime checks** (rust-lang/rust#148766): `Rvalue::NullaryOp`/`NullOp` were removed and the `ub`/`contract`/`overflow` checks moved to `Operand::RuntimeChecks`; update the CPROVER and LLBC codegen and the related analyses. - **`unsized_fn_params`**: the updated std passes unsized values by value (e.g. `impl … for [&str]`). Represent unsized-by-value arguments as fat pointers so they codegen instead of triggering an ICE (test under `tests/kani/UnsizedFnParams`). - Smaller adaptations: `FieldsShape::…::in_memory_order` (rust-lang/rust#150116), the new `ValueAbi::ScalableVector` variant, the `HumanReadableErrorType` struct form, coercion/safety cleanups (rust-lang/rust#148602), a refreshed `pointer_generator_error` expected file, and a `clippy::result_large_err` allow. Resolves: model-checking#4623 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
This change fixes the behavior of the
name()function forCrateDefandInstancewhich should return absolute path of items. For local items, the crate name was missing.This resolves: rust-lang/rustc_public#109