Support impl for type parameter `impl<T> Trait for T`
See original GitHub issueCurrently we don’t look for impls like impl<T> Trait for T
, so this test fails
trait Trait {
fn foo(&self) {}
} //X
impl<T> Trait for T {}
struct X;
fn main() {
X.foo();
} //^
It is pretty easy to implement. Here we indexing the impl
by the type. We should check if type is a type parameter of this impl (go to parent psi, find type parameters declaration and check the type name is the same), then if it is a type parameter, save it to index with a specific key that is invalid identifier (like #). Then while finding impls retreive index twice: with actual type name and with our specific key.
You can find more info about how to start contributing to Intellij-Rust in CONTRIBUTING.md, and some info about our architecure in ARCHITECTURE.md. If you have any questions about this issue, you can ask them right here or in our gitter. If you decided to grab this issue, please leave a comment here and put yourself in the worklist.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
I’ve previously thought about it I want to grab it:)
@Undin I don’t see a much difference between
impl<T: Foo> for T
andimpl<T: Foo> for S<T>
in terms of trait boud matching. We do not support both =) So it’s another issue. (seeRsPreciseTraitMatchingTest
)@farodin91 no-no-no, #1649 is another problem