Skip to content

Commit e192706

Browse files
committed
Note a redundantly imported name is allowed to be used
We had mentioned and demonstrated that a name is allowed to be redundantly imported by multiple glob imports, but we hadn't said that it is allowed to then be *used*. Given the example that directly proceeds this, it seems important to make a note of that, so let's do that, and let's extend the example to demonstrate this.
1 parent 4991393 commit e192706

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/items/use-declarations.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ fn main() {
361361
}
362362
```
363363

364-
Multiple glob imports are allowed to import the same name if the imports are of the same item (following re-exports). The visibility of the name is the maximum visibility of the imports. Example:
364+
Multiple glob imports are allowed to import the same name, and that name is allowed to be used, if the imports are of the same item (following re-exports). The visibility of the name is the maximum visibility of the imports. Example:
365365

366366
```rust
367367
mod foo {
@@ -372,12 +372,15 @@ mod bar {
372372
pub use super::foo::Qux;
373373
}
374374

375-
// These both import the same `Qux`.
376-
// The visibility of `Qux` is `pub` because that is the maximum
377-
// visibility between these two `use` declarations.
378-
use foo::*;
375+
// These both import the same `Qux`. The visibility of `Qux`
376+
// is `pub` because that is the maximum visibility between
377+
// these two `use` declarations.
379378
pub use bar::*;
380-
# fn main() {}
379+
use foo::*;
380+
381+
fn main() {
382+
let _: Qux = Qux;
383+
}
381384
```
382385

383386
[_SimplePath_]: ../paths.md#simple-paths

0 commit comments

Comments
 (0)