Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rust 2018 "Path and module system changes" for Rust 1.72 #285

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 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 @@ -272,7 +277,7 @@ enough to have submodules.
In Rust 2018, paths in `use` declarations and in other code work the same way,
both in the top-level module and in any submodule. You can use a relative path
from the current scope, a path starting from an external crate name, or a path
starting with `crate`, `super`, or `self`.
starting with `::`, `crate`, `super`, or `self`.

Code that looked like this:

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.