-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
base: master
Are you sure you want to change the base?
Conversation
r? @davidtwco rustbot has assigned @davidtwco. Use |
This PR changes a file inside |
LL | let () = x; | ||
| ^^ - this expression has type `impl Foo<bar!()>` | ||
| | | ||
| expected type parameter `impl Foo<bar!()>`, found `()` |
There was a problem hiding this comment.
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.
r=me if @petrochenkov is happy since he's also assigned |
flipping state back b/c of a pending question @rustbot ready |
This comment was marked as resolved.
This comment was marked as resolved.
#142690 should help with #142393 (comment) |
Yeah, I don't think it matters which node id was being used as a key. I think that PR + using the ty's node id is sufficient. |
This comment was marked as resolved.
This comment was marked as resolved.
@rustbot ready |
@bors r+ |
…enkov Don't give APITs names with macro expansion placeholder fragments in it 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 rust-lang#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 rust-lang#140333
The
DefCollector
previously calledpprust::ty_to_string
to construct a name for APITs (arg-position impl traits). Theast::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