-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Allow trait method references from the trait name (#3774)
# Description ## Problem\* Resolves #3773 Part of #2568 ## Summary\* This PR implements the ability to be able to call trait methods such as `Default::default()` where previously we required `StructName::default()`. The specific impl is selected via type inference. Previously, this resulted in a compiler panic. ## Additional Context When a trait method's type isn't constrained enough or is otherwise still ambiguous after type inference, the compiler currently just selects the first trait implementation that matches. E.g. `let _ = Default::default();`. This is a separate issue, so I'll create a new issue for this. ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[Exceptional Case]** Documentation to be submitted in a separate PR. - I think traits are finally stable enough to start writing documentation for. I'm going to submit another PR to remove some of the experimental warnings the compiler has for traits, and with it add documentation for traits as well. This wouldn't stabilize all trait features (e.g. associated types are still unimplemented), but users will now be able to use basic traits with functions without warnings. Any unimplemented trait items (associated types again) will not be included in the documentation. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: kevaundray <[email protected]>
- Loading branch information
1 parent
ce80f5a
commit cfa34d4
Showing
9 changed files
with
209 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.