From e5f1c02e1009691c6d74e42fb6438c992c3f4b1b Mon Sep 17 00:00:00 2001 From: Matthew Woodcraft Date: Wed, 6 Sep 2023 20:45:05 +0100 Subject: [PATCH] rust-2018/path-changes: updates for Rust 1.72 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. --- src/rust-2018/path-changes.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/rust-2018/path-changes.md b/src/rust-2018/path-changes.md index 09886a19..60bf1155 100644 --- a/src/rust-2018/path-changes.md +++ b/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: @@ -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.