Uh oh!
There was an error while loading. Please reload this page.
Remove last uses of gensyms - #64623
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
90eef3e to
da01d31CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Hmm, I'd expect every _ name to get SyntaxContext from a fresh macro expansion with def-site in empty_module, like it was done for other gensyms in #63919.
Thus we'll reuse the same common mechanism, and when hygiene data becomes encodable we'll be able to properly encode _s in metadata as well, thus resolving the "FIXME: We shouldn't create the gensym here" below.
There was a problem hiding this comment.
Glob imports operate on the actual hygiene data: https://github.com/rust-lang/rust/blob/da01d31ff97feb199036359c364aedc809711123/src/librustc_resolve/resolve_imports.rs#L563
I'll see if there's a way to do this without increasing the complexity of reverse_glob_adjust
There was a problem hiding this comment.
Ah, right, the difference is that _s bring traits into scope for the purpose of type-based resolution, and names from opaque macros don't.
This difference is orthogonal to globs, so perhaps it's collection of traits in scope that needs to be adjusted, not reverse_glob_adjust.
(It's somewhat unfortunate that the difference exists and the features cannot be fully unified, but in both cases the behavior looks entirely reasonable and appropriate.)
There was a problem hiding this comment.
I'm specifically concerned about preserving the behavior of the following:
mod x {useTraitas _;}use x::*;fnf(){().method_on_trait();// ^This resolves if the whole snippet comes from a single macro expansion// It generally doesn't resolve otherwise}I think I have a working solution for this, which I'll push once I'm happy.
nnethercote
left a comment
There was a problem hiding this comment.
I'd be interested to see a perf run on this before it lands, see if it improves things.
Uh oh!
There was an error while loading. Please reload this page.
06e5858 to
50660a1Comparematthewjasper
commented
Sep 28, 2019
@bors try @rust-timer queue |
rust-timer
commented
Sep 28, 2019
Awaiting bors try build completion |
bors
commented
Sep 28, 2019
⌛ Trying commit 50660a1817e3c403c532dfcdd15210917a653921 with merge a9bcdfe8870fc7bed62b6bb47e31b50629067f15... |
bors
commented
Sep 28, 2019
☀️ Try build successful - checks-azure |
rust-timer
commented
Sep 28, 2019
Queued a9bcdfe8870fc7bed62b6bb47e31b50629067f15 with parent f3c8eba, future comparison URL. |
rust-timer
commented
Sep 28, 2019
Finished benchmarking try commit a9bcdfe8870fc7bed62b6bb47e31b50629067f15, comparison URL. |
Having a quick look at unused-warnings, I think this is caused by the sorting of reexports. I'll investigate properly tomorrow. |
nnethercote
commented
Sep 29, 2019
|
50660a1 to
0e1c0b5Comparematthewjasper
commented
Sep 29, 2019
@bors try @rust-timer queue |
rust-timer
commented
Sep 29, 2019
Awaiting bors try build completion |
bors
commented
Sep 29, 2019
Remove last uses of gensyms Bindings are now indexed in resolve with an additional disambiguator that's used for underscore bindings. This is the last use of gensyms in the compiler. I'm not completely happy with this approach, so suggestions are welcome. Moving undescore bindings into their own map didn't turn out any better: master...matthewjasper:remove-underscore-gensyms. closes#49300 cc #60869 r? @petrochenkov
bors
commented
Sep 29, 2019
☀️ Try build successful - checks-azure |
rust-timer
commented
Sep 29, 2019
Queued 3498eec with parent d046ffd, future comparison URL. |
rust-timer
commented
Sep 30, 2019
Finished benchmarking try commit 3498eec, comparison URL. |
JohnCSimon
commented
Oct 12, 2019
Ping from triage |
petrochenkov
commented
Oct 12, 2019
I didn't forget about this, just need some continuous period of time to focus on this. |
petrochenkov
commented
Oct 13, 2019
So, I still want to pursue the approach with underscores mostly being identifiers with def-site spans produced by unique macros defined in the empty module, with all special casing done for code collecting traits in scope (the only detail in which the underscores are different). That's why I started looking at the existing code determining the set of traits in scope and I didn't like what I had seen. |
petrochenkov
commented
Oct 13, 2019
@matthewjasper |
bc38b56 to
bdb37e5CompareUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
What happens if this special case is removed? Some diagnostics regress?
There was a problem hiding this comment.
I don't think so, we just won't be able to remove it in resolve_imports.rs:831.
There was a problem hiding this comment.
Ah, I see, the disambiguator is not available in that context.
petrochenkov
commented
Oct 15, 2019
r=me with the typo #64623 (comment) fixed or not |
Instead add a disambiguator to the keys used for distinguishing resolutions.
bdb37e5 to
4198df1Comparematthewjasper
commented
Oct 15, 2019
@bors r=petrochenkov |
bors
commented
Oct 15, 2019
📌 Commit 4198df1 has been approved by |
…=petrochenkov Remove last uses of gensyms Underscore bindings now use unique `SyntaxContext`s to avoid collisions. This was the last use of gensyms in the compiler, so this PR also removes them. closesrust-lang#49300 cc rust-lang#60869 r? @petrochenkov
Rollup of 14 pull requests Successful merges: - #64603 (Reducing spurious unused lifetime warnings.) - #64623 (Remove last uses of gensyms) - #65235 (don't assume we can *always* find a return type hint in async fn) - #65242 (Fix suggestion to constrain trait for method to be found) - #65265 (Cleanup librustc mir err codes) - #65293 (Optimize `try_expand_impl_trait_type`) - #65307 (Try fix incorrect "explicit lifetime name needed") - #65308 (Add long error explanation for E0574) - #65353 (save-analysis: Don't ICE when resolving qualified type paths in struct members) - #65389 (Return `false` from `needs_drop` for all zero-sized arrays.) - #65402 (Add troubleshooting section to PGO chapter in rustc book.) - #65425 (Optimize `BitIter`) - #65438 (Organize `never_type` tests) - #65444 (Implement AsRef<[T]> for List<T>) Failed merges: - #65390 (Add long error explanation for E0576) r? @ghost
Underscore bindings now use unique
SyntaxContexts to avoid collisions. This was the last use of gensyms in the compiler, so this PR also removes them.closes#49300
cc #60869
r? @petrochenkov