diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /src/doc/edition-guide | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/doc/edition-guide')
-rw-r--r-- | src/doc/edition-guide/src/rust-2018/path-changes.md | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/doc/edition-guide/src/rust-2018/path-changes.md b/src/doc/edition-guide/src/rust-2018/path-changes.md index ca2c27ca2..60bf1155e 100644 --- a/src/doc/edition-guide/src/rust-2018/path-changes.md +++ b/src/doc/edition-guide/src/rust-2018/path-changes.md @@ -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: @@ -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: @@ -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. |