Skip to content

Commit 9ec720b

Browse files
traviscrossehuss
authored andcommitted
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 163f7bc commit 9ec720b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/items/use-declarations.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ fn main() {
364364
}
365365
```
366366

367-
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:
367+
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:
368368

369369
```rust
370370
mod foo {
@@ -375,12 +375,15 @@ mod bar {
375375
pub use super::foo::Qux;
376376
}
377377

378-
// These both import the same `Qux`.
379-
// The visibility of `Qux` is `pub` because that is the maximum
380-
// visibility between these two `use` declarations.
381-
use foo::*;
378+
// These both import the same `Qux`. The visibility of `Qux`
379+
// is `pub` because that is the maximum visibility between
380+
// these two `use` declarations.
382381
pub use bar::*;
383-
# fn main() {}
382+
use foo::*;
383+
384+
fn main() {
385+
let _: Qux = Qux;
386+
}
384387
```
385388

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

0 commit comments

Comments
 (0)