Skip to content

Commit 34fca48

Browse files
authored
Merge pull request #285 from mattheww/2023-09_paths
Update Rust 2018 "Path and module system changes" for Rust 1.72
2 parents 2751bdc + e5f1c02 commit 34fca48

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/rust-2018/path-changes.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ mod submodule {
206206
}
207207
```
208208

209+
If you have a local module or item with the same name as an external crate, a
210+
path begining with that name will be taken to refer to the local module or
211+
item. To explicitly refer to the external crate, use the `::name` form.
212+
213+
209214
### No more `mod.rs`
210215

211216
In Rust 2015, if you have a submodule:
@@ -272,7 +277,7 @@ enough to have submodules.
272277
In Rust 2018, paths in `use` declarations and in other code work the same way,
273278
both in the top-level module and in any submodule. You can use a relative path
274279
from the current scope, a path starting from an external crate name, or a path
275-
starting with `crate`, `super`, or `self`.
280+
starting with `::`, `crate`, `super`, or `self`.
276281

277282
Code that looked like this:
278283

@@ -371,9 +376,3 @@ mod submodule {
371376

372377
This makes it easy to move code around in a project, and avoids introducing
373378
additional complexity to multi-module projects.
374-
375-
If a path is ambiguous, such as if you have an external crate and a local
376-
module or item with the same name, you'll get an error, and you'll need to
377-
either rename one of the conflicting names or explicitly disambiguate the path.
378-
To explicitly disambiguate a path, use `::name` for an external crate name, or
379-
`self::name` for a local module or item.

0 commit comments

Comments
 (0)