-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Get "does not implement any method" if module w/ trait use'd, but not when trait imported #21049
Comments
This is expected behaviour. The trait has to be in scope for it to be considered for method resolution. The error message could be more helpful, but that's a separate issue, specifically, #7643. Closing in favor of that. |
This is a different issue. In #7643, the module was not
|
I'd also add that if this behavior is expected, it is inconsistent between library traits and user defined traits. For example, the statement |
@arienmalec there is not any inconsistency. |
I can call the |
The following code fails with " error: type
objs::Obj
does not implement any method in scope namedfoo
"but works when main is changed to specifically import the trait:
Note that the only difference between these two versions is whether
Foo
is addressable asFoo
or astraits::Foo
; in either case the trait has been included in scope; that is, the only difference is changing:use traits;
to
use traits::{Foo};
The text was updated successfully, but these errors were encountered: