Skip to content

Commit f4694db

Browse files
committed
Address MR’s comments.
1 parent 17a50ea commit f4694db

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

text/0000-impl-only-use.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Summary
77
[summary]: #summary
88

9-
The `use … (… as …)` syntax can now accept a wildcard `_` as alias to a trait to only import the
9+
The `use …::{… as …}` syntax can now accept `_` as alias to a trait to only import the
1010
implementations of such a trait.
1111

1212
# Motivation
@@ -88,7 +88,30 @@ The `_` means that you “don’t care about the name rustc will use for that qu
8888
# Reference-level explanation
8989
[reference-level-explanation]: #reference-level-explanation
9090

91-
To be defined.
91+
`use Trait as _` needs to desugar into `use Trait as SomeGenSym`. With this scheme, global imports
92+
and exports can work properly with such items, i.e. import / re-export them.
93+
94+
```rust
95+
mod m {
96+
pub use Trait as _;
97+
98+
// `Trait` is in scope
99+
}
100+
101+
use m::*;
102+
103+
// `Trait` is in scope too
104+
```
105+
106+
In the case where the symbol is not a *trait*, it works the exact same way. However, a warning must
107+
be emitted by the compiler to state the unused import (as types don’t have `impl`!).
108+
109+
In the same way, it’s possible to use the same mechanism with `extern crate` for linking-only
110+
crates:
111+
112+
```rust
113+
extern crate my_crate as _;
114+
```
92115

93116
# Drawbacks
94117
[drawbacks]: #drawbacks

0 commit comments

Comments
 (0)