Skip to content

Commit db220a9

Browse files
committed
Revise editorially
1 parent 3739f33 commit db220a9

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/names/name-resolution.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,29 @@ use m::A::V; // ERROR: Unresolved import `m::A::V`.
110110
```
111111

112112
r[names.resolution.expansion.imports.shadowing]
113-
Names introduced via `use` declarations in an [outer scope] are shadowed by
114-
candidates in the same namespace with the same name from an inner scope except
115-
where otherwise restricted by [name resolution ambiguities].
113+
Names introduced via `use` declarations in an [outer scope] are shadowed by candidates in the same namespace with the same name from an inner scope except where otherwise restricted by [name resolution ambiguities].
116114

117-
```rust
118-
pub mod foo {
119-
pub mod baz {
120-
pub struct Name;
115+
```rust,no_run
116+
pub mod m1 {
117+
pub mod ambig {
118+
pub const C: u8 = 1;
121119
}
122120
}
123121
124-
pub mod bar {
125-
pub mod baz {
126-
pub struct Name(pub ());
122+
pub mod m2 {
123+
pub mod ambig {
124+
pub const C: u8 = 2;
127125
}
128126
}
129127
130-
use foo::baz;
128+
// This introduces the name `ambig` in the outer scope.
129+
use m1::ambig;
131130
fn f() {
132-
use bar::baz;
133-
use baz::Name;
134-
Name(());
131+
// This shadows `ambig` in the inner scope.
132+
use m2::ambig;
133+
// The `use` from the inner scope is used here.
134+
use ambig::C;
135+
const { assert!(C == 2) };
135136
}
136137
```
137138

0 commit comments

Comments
 (0)