-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
methods in trait impls should override default methods #18446
Comments
To explain what needs doing and why I didn't just do it as part of #17750: Resolve works by creating modules for namespaces. In the above example there will a top level module, then should create separate modules for the trait T and the impl T. However, resolve uses an ast::Name to lookup these modules. So, when it gets to the impl, it tries to find a module for The fix, I suppose, is to use something other than just an ast::Name as the key for looking up namespace modules (perhaps a NodeId or a key object combining a kind of item and a Name). But this is a relatively major change to resolve, so I think it is worth separating out from the implementation work for #17750. |
When we do this, we must check (and add a test for) coherence still working with trait impls. E.g.,
Here, This is not possible right now because there will a name clash between the required method in the trait and the provided method in the trait impl. |
Interesting. Per the UFCS RFC, T::foo should resolve to the trait, and |
This compiles now. Someone apply the 'needs-test' label |
Fixed by #40296 |
fix: Only parse `safe` as contextual kw in extern blocks
E.g.,
Should be OK. (It currently gives "duplicate definition of value
foo
").Follow up to #17750
The text was updated successfully, but these errors were encountered: