Skip to content

Commit 6d1c8f2

Browse files
committed
Addressed some review comments.
1 parent ff679c0 commit 6d1c8f2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

text/0000-import-trait-associated-functions.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,12 @@ Trait::func(x, y, z);
159159

160160
Additionally, the syntax
161161
```rust
162-
use some_module::Trait::self;
162+
use Trait::{self, func};
163163
```
164164
is sugar for
165165
```rust
166166
use some_module::Trait;
167-
```
168-
to allow importing a trait and its methods at the same time, e.g:
169-
```rust
170-
use Default::{self, default};
167+
use some_module::Trait::func;
171168
```
172169

173170
The restriction on importing parent trait associated functions is a consequence of this desugaring, see https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=51bef9ba69ce1fc20248e987bf106bd4 for examples of the errors you get when you try to call parent trait associated functions through a child trait. We will likely want better error messages than this if a user tries to import a parent function.
@@ -184,7 +181,7 @@ This recommendation makes the most sense when there is a possibility of ambiguit
184181

185182
Because of this context sensitivity, we should allow developers to choose when removing the extra context makes sense for their codebase.
186183

187-
Another drawback mentioned during review for this RFC was that this adds more complication to the name resolution rules. On an implementation side, I am assured that this feature is straightforward to implement. From a user perspective, the name lookup rules for the function name are exactly the same as those used to look up any other function name. The lookup rules used to resolve the `impl` are also exactly the same ones used for non-fully qualified trait function calls. There is no fundamentally new kind of lookup happening here, just a remixing of existing lookup rules.
184+
Another drawback mentioned during review for this RFC was that this adds more complication to the name resolution rules. On an implementation side, I am assured that this feature is straightforward to implement in rustc. From a user perspective, the name lookup rules for the function name are exactly the same as those used to look up any other function name. The lookup rules used to resolve the `impl` are also exactly the same ones used for non-fully qualified trait function calls. There is no fundamentally new kind of lookup happening here, just a remixing of existing lookup rules.
188185

189186
# Rationale and alternatives
190187
[rationale-and-alternatives]: #rationale-and-alternatives

0 commit comments

Comments
 (0)