Skip to content

Commit

Permalink
rust-2018/path-changes: updates for Rust 1.72
Browse files Browse the repository at this point in the history
Since rust-lang/rust#112086, paths in `use` statements have the same shadowing
rules as other paths, at least for the simple cases we're talking about in
this guide.

The case of an external crate having the same name as a local module still
seems worth mentioning, so I've put it in the "Extern crate paths" section.
  • Loading branch information
mattheww committed Sep 6, 2023
1 parent 1ff3909 commit e5f1c02
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/rust-2018/path-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ mod submodule {
}
```

If you have a local module or item with the same name as an external crate, a
path begining with that name will be taken to refer to the local module or
item. To explicitly refer to the external crate, use the `::name` form.


### No more `mod.rs`

In Rust 2015, if you have a submodule:
Expand Down Expand Up @@ -371,9 +376,3 @@ mod submodule {

This makes it easy to move code around in a project, and avoids introducing
additional complexity to multi-module projects.

If a path is ambiguous, such as if you have an external crate and a local
module or item with the same name, you'll get an error, and you'll need to
either rename one of the conflicting names or explicitly disambiguate the path.
To explicitly disambiguate a path, use `::name` for an external crate name, or
`self::name` for a local module or item.

0 comments on commit e5f1c02

Please sign in to comment.