-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Partial implementation for UFCS trait-less associated paths. #22172
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
very cool, I will read. |
@eddyb sorry for being slow. I spent some time reading into this two days back but yesterday got very busy. I expect to finish up today. |
First off, some nits here: nikomatsakis@b6461f0 |
r+, awesome! But I did have some conditions and comments :) Conditions:
Comments/Questions: I still feel like a reworking of resolve and the data structures around resolve (notably, Path and Def) could yield substantially cleaner code, but this seems to be overall a pretty reasonable approach. One thing I noticed that stuck out at me: in resolve, if parsing I also found the "suppress errors" flag a little bit suboptimal, compared to passing back an error as a result, but it's a relatively minor thing. In general I'd like to see resolution refactored into a "side-effect-free" lookup that returns errors / successful results, leaving it to the caller to decide what to do with those. I was happy to see you integrated the lookup into probe. |
b7dd4cc
to
43bac21
Compare
@eddyb ok, so I finished reviewing as of 43bac21. Let's call them concerns, for the most part -- more than nits, but certainly not blockers. Anyway, I'd appreciate clarification about the potential for ICEs etc. I'd like to have a change to look over the patch once you address them -- or tell me why I am wrong --- but promise to make it quick presuming major changes aren't needed. |
dc4043a
to
7af58b8
Compare
@bors r=nikomatsakis 7af58b8 |
⌛ Testing commit 7af58b8 with merge de86968... |
💔 Test failed - auto-linux-64-x-android-t |
💔 Test failed - auto-mac-32-opt |
@bors r=nikomatsakis 6e58a42 |
⌛ Testing commit 6e58a42 with merge bf9938f... |
💔 Test failed - auto-mac-64-nopt-t |
@bors r=nikomatsakis e979cf4 |
⌛ Testing commit 0c6d1f3 with merge f33e2e2... |
💔 Test failed - auto-win-32-nopt-t |
@bors: retry force |
@bors: force |
⌛ Testing commit 0c6d1f3 with merge 695bde9... |
⌛ Testing commit 0c6d1f3 with merge 0b975cb... |
💔 Test failed - auto-win-32-nopt-t |
@bors: retry |
Adds `<module::Type>::method` support and makes `module::Type::method` a shorthand for it. This is most of #16293, except that chaining multiple associated types is not yet supported. It also fixes #22563 as `impl`s are no longer treated as modules in resolve. Unfortunately, this is still a *[breaking-change]*: * If you used a global path to a primitive type, i.e. `::bool`, `::i32` etc. - that was a bug I had to fix. Solution: remove the leading `::`. * If you passed explicit `impl`-side type parameters to an inherent method, e.g.: ```rust struct Foo<T>(T); impl<A, B> Foo<(A, B)> { fn pair(a: A, b: B) -> Foo<(A, B)> { Foo((a, b)) } } Foo::<A, B>::pair(a, b) // Now that is sugar for: <Foo<A, B>>::pair(a, b) // Which isn't valid because `Foo` has only one type parameter. // Solution: replace with: Foo::<(A, B)>::pair(a, b) // And, if possible, remove the explicit type param entirely: Foo::pair(a, b) ``` * If you used the `QPath`-related `AstBuilder` methods @hugwijst added in #21943. The methods still exist, but `QPath` was replaced by `QSelf`, with the actual path stored separately. Solution: unpack the pair returned by `cx.qpath` to get the two arguments for `cx.expr_qpath`.
Now possible thanks to rust-lang/rust#22172
Now possible thanks to rust-lang/rust#22172
Now possible thanks to rust-lang/rust#22172
Adds
<module::Type>::method
support and makesmodule::Type::method
a shorthand for it.This is most of #16293, except that chaining multiple associated types is not yet supported.
It also fixes #22563 as
impl
s are no longer treated as modules in resolve.Unfortunately, this is still a [breaking-change]:
::bool
,::i32
etc. - that was a bug I had to fix.Solution: remove the leading
::
.impl
-side type parameters to an inherent method, e.g.:QPath
-relatedAstBuilder
methods @hugwijst added in Add QPath construction to ExtCtxt for UFCS support. #21943.The methods still exist, but
QPath
was replaced byQSelf
, with the actual path stored separately.Solution: unpack the pair returned by
cx.qpath
to get the two arguments forcx.expr_qpath
.