-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Give return-position impl traits in trait a (synthetic) name to avoid name collisions with new lowering strategy #109455
Give return-position impl traits in trait a (synthetic) name to avoid name collisions with new lowering strategy #109455
Conversation
r? @Nilstrieb (rustbot has picked a reviewer for you, use r? to override) |
@@ -281,7 +281,7 @@ pub enum DefPathData { | |||
/// An `impl Trait` type node. | |||
ImplTrait, | |||
/// `impl Trait` generated associated type node. | |||
ImplTraitAssocTy, | |||
ImplTraitAssocTy(Symbol), |
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.
I guess there's no real reason why this needs to be a separate def path data. We could use TypeNs
here now, (I guess) as long as we keep the actual name that the RPITIT is lowering to unnameable.
4624429
to
492edeb
Compare
Btw, it looks good to me but I'd leave this up to @petrochenkov given that they've self-assigned it. |
This comment was marked as resolved.
This comment was marked as resolved.
492edeb
to
602cf24
Compare
I think this is a big unnecessary complication. |
It's kind of a philosophical question what exactly should go into the Right now only named items that are actually planted into modules and visible to other modules/crates in this way are put into the Also Are synthetic RPITITs similar to (I think I have a weak preference for separate lists for both after all.) |
I don't think this is really complicated, the meat of the change is 602cf24 and the change also help to make diagnostics be equal to master as seen in https://github.com/rust-lang/rust/pull/109455/files#diff-2245ba262b8ba2866c27f1ac3f76db96146870beb91a6ac7ce621ca2cbb7c501R9. Although I guess that could also be |
☔ The latest upstream changes (presumably #109496) made this pull request unmergeable. Please resolve the merge conflicts. |
It's not very complicated, it's just unnecessarily complicated (I'm only talking about the last commit, others seem unrelated). |
I don't think is going to break, you would end with Anyway, would leave this up to be answered by @compiler-errors |
Closing in favor of #109499 |
…-errors Give return-position impl traits in trait a (synthetic) name to avoid name collisions with new lowering strategy The only needed commit from this PR is the last one. r? `@compiler-errors` Needs rust-lang#109455.
We were previously lowering RPITITs to associated items with the name "
kw::Empty
", which as petrochenkov predicted, causes name collisions when being decoded from foreign crates.Instead, synthesize a name by concatenating the def-path segments of the original RPITIT, something like
foo::{opaque#1}
orfoo::{opaque#0}::{opaque#0}
. This should keep the item unnameable, since we never want to name it as that would be problematic as we lower these items after the resolver is run.Also, fix a few unrelated bugs with nested RPITITs, and beefen up the foreign encoding test.
cc @petrochenkov and the test case described here: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/-Z.20lower-impl-trait-in-trait-to-assoc-ty.20summary.3F/near/343451927