Skip to content

Conversation

@celinval
Copy link
Contributor

@celinval celinval commented Nov 27, 2025

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/project-stable-mir#109

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/project-stable-mir#109
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 27, 2025

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

56         _3 = (*_4);
57         _5 = ();
58         StorageDead(_3);
-         _0 = std::task::Poll::Ready(move _5);
+         _0 = Poll::Ready(move _5);
60         discriminant((*_7)) = 1;
61         return;
62     }

88         _3 = (*_4);
89         _5 = ();
90         StorageDead(_3);
-         _0 = std::task::Poll::Ready(move _5);
+         _0 = Poll::Ready(move _5);
92         discriminant((*_7)) = 1;
93         return;
94     }


The actual stdout differed from the expected stdout
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args rustc_public-ir-print/async-closure.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/rustc_public-ir-print/async-closure.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/rustc_public-ir-print/async-closure" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2024" "-Z" "unpretty=stable-mir" "--crate-type" "lib" "-C" "panic=abort" "-Zmir-opt-level=0"
--- stdout -------------------------------
// 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 foo() -> () {
    let mut _0: ();
    let  _1: i32;
    let  _2: {async closure@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:13: 9:21};
    let mut _3: &i32;
    debug y => _1;
    debug x => _2;
    bb0: {
        StorageLive(_1);
        _1 = 0_i32;
        StorageLive(_2);
        StorageLive(_3);
        _3 = &_1;
        _2 = {coroutine-closure@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:13: 9:21}(move _3);
        StorageDead(_3);
        _0 = ();
        StorageDead(_2);
        StorageDead(_1);
        return;
    }
}
fn foo::{closure#0}(_1: &{async closure@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:13: 9:21}) -> {async closure body@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6} {
    let mut _0: {async closure body@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6};
    let mut _2: &i32;
    let mut _3: &i32;
    debug y => (*((*_1).0: &i32));
    bb0: {
        StorageLive(_2);
        _3 = ((*_1).0: &i32);
        _2 = &(*_3);
        _0 = {coroutine@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6}(move _2);
        StorageDead(_2);
        return;
    }
}
fn foo::{closure#0}::{closure#0}(_1: Pin<&mut {async closure body@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6}>, _2: &mut Context<'_>) -> Poll<()> {
    let mut _0: Poll<()>;
    let  _3: i32;
    let mut _4: &i32;
    let mut _5: ();
    let mut _6: u32;
    let mut _7: &mut {async closure body@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6};
    debug _task_context => _2;
    debug y => (*((*_7).0: &i32));
    debug y => _3;
    bb0: {
        _7 = (_1.0: &mut {async closure body@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6});
        _6 = discriminant((*_7));
        switchInt(move _6) -> [0: bb1, 1: bb2, otherwise: bb3];
    }
    bb1: {
        StorageLive(_3);
        _4 = ((*_7).0: &i32);
        _3 = (*_4);
        _5 = ();
        StorageDead(_3);
        _0 = Poll::Ready(move _5);
        discriminant((*_7)) = 1;
        return;
    }
    bb2: {
        assert(false, `async fn` resumed after completion) -> [success: bb2, unwind unreachable];
    }
    bb3: {
        unreachable;
    }
}
fn foo::{closure#0}::{synthetic#0}(_1: Pin<&mut {async closure body@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6}>, _2: &mut Context<'_>) -> Poll<()> {
    let mut _0: Poll<()>;
    let  _3: i32;
    let mut _4: &i32;
    let mut _5: ();
    let mut _6: u32;
    let mut _7: &mut {async closure body@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6};
    debug _task_context => _2;
    debug y => (*((*_7).0: &i32));
    debug y => _3;
    bb0: {
        _7 = (_1.0: &mut {async closure body@/checkout/tests/ui/rustc_public-ir-print/async-closure.rs:9:22: 11:6});
        _6 = discriminant((*_7));
        switchInt(move _6) -> [0: bb1, 1: bb2, otherwise: bb3];
    }
    bb1: {
        StorageLive(_3);
        _4 = ((*_7).0: &i32);
        _3 = (*_4);
        _5 = ();
        StorageDead(_3);
        _0 = Poll::Ready(move _5);
        discriminant((*_7)) = 1;
        return;
    }
    bb2: {
        assert(false, `async fn` resumed after completion) -> [success: bb2, unwind unreachable];
    }
    bb3: {
        unreachable;
    }
}

@celinval
Copy link
Contributor Author

celinval commented Nov 27, 2025

It looks like I need to do some debugging. It's not clear to me why this change affected these tests. I.e., why:

std::task::Poll::Ready -> Poll::Ready
std::option::Option::None -> Option::None

It seems to only affect std ADTs variants.

EDIT: Looking at the pretty print file, before this change, the types Option and Arguments did not include absolute path, but the variant std::option::Option::None did. This uses display not path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function path is stripped of root for local crate

4 participants