Skip to content

Don't give APITs names with macro expansion placeholder fragments in it #142393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jun 12, 2025

The DefCollector previously called pprust::ty_to_string to construct a name for APITs (arg-position impl traits). The ast::Ty that was being formatted however has already had its macro calls replaced with "placeholder fragments", which end up rendering like !() (or ICEing, in the case of #140333, since it led to a placeholder struct field with no name).

Instead, collect the name of the APIT before we visit its macros and replace them with placeholders in the macro expander. This makes the implementation a bit more involved, but AFAICT there's no better way to do this since we can't do a reverse mapping from placeholder fragment -> original macro call AST.

Fixes #140333

@rustbot
Copy link
Collaborator

rustbot commented Jun 12, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
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

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

rustbot commented Jun 12, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

LL | let () = x;
| ^^ - this expression has type `impl Foo<bar!()>`
| |
| expected type parameter `impl Foo<bar!()>`, found `()`
Copy link
Member Author

@compiler-errors compiler-errors Jun 12, 2025

Choose a reason for hiding this comment

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

For contrast, this used to render like impl Foo<!()>, where !() is the placeholder fragment.

@petrochenkov petrochenkov self-assigned this Jun 12, 2025
@davidtwco
Copy link
Member

r=me if @petrochenkov is happy since he's also assigned

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.

ICE: None in pretty printing self.print_ident(field.ident.unwrap());
4 participants