From d77edb6458f6eafa61ff7a5c2bef3b613add80a1 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 28 Nov 2018 22:52:58 +0300 Subject: [PATCH] resolve: Fix false-positives from lint `absolute_paths_not_starting_with_crate` --- src/librustc_resolve/lib.rs | 2 +- src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs | 11 +++++++++++ src/test/ui/rust-2018/edition-lint-paths-2018.rs | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/rust-2018/edition-lint-paths-2018.rs diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index cbf82a80266..c1d4643c240 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3950,7 +3950,7 @@ fn lint_if_path_starts_with_module( let first_name = match path.get(0) { // In the 2018 edition this lint is a hard error, so nothing to do - Some(seg) if seg.ident.span.rust_2015() => seg.ident.name, + Some(seg) if seg.ident.span.rust_2015() && self.session.rust_2015() => seg.ident.name, _ => return, }; diff --git a/src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs b/src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs index cc17a9bd661..dc4ab2131a8 100644 --- a/src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs +++ b/src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs @@ -9,3 +9,14 @@ // except according to those terms. pub fn foo() {} + +#[macro_export] +macro_rules! macro_2015 { + () => { + use edition_lint_paths as other_name; + use edition_lint_paths::foo as other_foo; + fn check_macro_2015() { + ::edition_lint_paths::foo(); + } + } +} diff --git a/src/test/ui/rust-2018/edition-lint-paths-2018.rs b/src/test/ui/rust-2018/edition-lint-paths-2018.rs new file mode 100644 index 00000000000..09b31beb775 --- /dev/null +++ b/src/test/ui/rust-2018/edition-lint-paths-2018.rs @@ -0,0 +1,10 @@ +// compile-pass +// edition:2018 +// compile-flags:--extern edition_lint_paths +// aux-build:edition-lint-paths.rs + +#![deny(absolute_paths_not_starting_with_crate)] + +edition_lint_paths::macro_2015!(); // OK + +fn main() {} -- 2.44.0