You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
main.rs:19:6: 19:12 error: unresolved name
main.rs:19 T::act();
^~~~~~
main.rs:19:6: 19:12 error: use of undeclared module `T`
main.rs:19 T::act();
^~~~~~
main.rs:19:6: 19:12 error: unresolved name `T::act`. Did you mean `val`?
main.rs:19 T::act();
The text was updated successfully, but these errors were encountered:
This is a "feature" (well, a bug too, but it's well covered elsewhere, e.g. #6894). Static methods need to be called like MyTrait::act(). However, this doesn't allow the Self type to be infered correctly. The standard work around is using a dummy parameter that mentions Self. e.g.
Thanks for the answer!
But will it be fixed sometime? I mean, this workaround is really messy. It might be that i don't even own the MyTrait code, so i can't change it.
But my act actually returned Self, so i didn't even use this hack.
Yes, it will be fixed; the RFC I linked above is proposing a fix, but there is still some discussion happening in this area.
If you don't own MyTrait and the static methods don't have a workaround like this, then no-one can use them, not even the original library, i.e. the library is fundamentally broken.
Is this a bug or a feature?
Gives:
The text was updated successfully, but these errors were encountered: