Skip to content

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Sep 7, 2025

Fixes #146249.

r? @lcnr

@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 Sep 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 7, 2025

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@rustbot

This comment has been minimized.

@nnethercote
Copy link
Contributor Author

@lcnr: I don't know if this static region is expected or not, I just assumed it was ok.

@theemathas
Copy link
Contributor

Another test case:

struct Foo<T>(T);

impl Foo<&'static i32> {
    fn bar() {
        let f = || {};
        dbg!(std::any::type_name_of_val(&f));
    }
}

fn main() {
    <Foo<_>>::bar();
}

@theemathas
Copy link
Contributor

Another two test cases:

trait Trait {
    type Assoc;
}

impl<'a> dyn Trait<Assoc = &'static i32> + 'a {
    fn bar() {
        let f = || {};
        dbg!(std::any::type_name_of_val(&f));
    }
}

fn main() {
    <dyn Trait<Assoc = &'static i32>>::bar();
}
struct Thing<T, U>(T, U);

trait Trait {
    type Assoc<T>;
}
impl Trait for () {
    type Assoc<T> = ();
}

impl<T: Trait> Thing<T, T::Assoc<&'static i32>> {
    fn bar() {
        let f = || {};
        dbg!(std::any::type_name_of_val(&f));
    }
}

fn main() {
    Thing::<(), ()>::bar();
}

@nnethercote
Copy link
Contributor Author

Thanks for the extra test cases. I checked; they are all fixed by this PR's change.

@rustbot
Copy link
Collaborator

rustbot commented Sep 8, 2025

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@lcnr
Copy link
Contributor

lcnr commented Sep 8, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 8, 2025

📌 Commit 9a52a83 has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 8, 2025
@@ -168,10 +168,11 @@ impl<'tcx> PrettyPrinter<'tcx> for TypeNamePrinter<'tcx> {
// Bound regions are always printed (as `'_`), which gives some idea that they are special,
// even though the `for` is omitted by the pretty printer.
// E.g. `for<'a, 'b> fn(&'a u32, &'b u32)` is printed as "fn(&'_ u32, &'_ u32)".
let kind = region.kind();
match region.kind() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since kind now exists, maybe

Suggested change
match region.kind() {
match kind {

could be good?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, yes, it was meant to be like that.

bors added a commit that referenced this pull request Sep 8, 2025
Rollup of 7 pull requests

Successful merges:

 - #146111 (Migrate more things in the new solver to specific `DefId`s)
 - #146298 (GVN: Ensure indirect is first projection in try_as_place.)
 - #146299 (docs(std): add error docs for path canonicalize)
 - #146310 (Allow static regions in `type_name`.)
 - #146313 (Some `rustc_middle` cleanups)
 - #146319 (Fix typo in default.rs)
 - #146320 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 00bffaa into rust-lang:master Sep 8, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Sep 8, 2025
rust-timer added a commit that referenced this pull request Sep 8, 2025
Rollup merge of #146310 - nnethercote:fix-146249, r=lcnr

Allow static regions in `type_name`.

Fixes #146249.

r? `@lcnr`
@nnethercote nnethercote deleted the fix-146249 branch September 8, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

ICE (nightly): entered unreachable code when using closure type name inside impl Foo<Box<dyn FnOnce()>>
6 participants