about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-11-29 13:10:53 +0100
committerGitHub <noreply@github.com>2018-11-29 13:10:53 +0100
commit1fe2085441c5c9afc1523c19c1c1ddbf86bae462 (patch)
treeda58b57f77e422398e6e2a7f93a6af6b2fac0bd0
parentf20a1d7b5d2022e10b37362be88223e876c62fe3 (diff)
parentd77edb6458f6eafa61ff7a5c2bef3b613add80a1 (diff)
downloadrust-1fe2085441c5c9afc1523c19c1c1ddbf86bae462.tar.gz
rust-1fe2085441c5c9afc1523c19c1c1ddbf86bae462.zip
Rollup merge of #56322 - petrochenkov:edlints, r=eddyb
resolve: Fix false-positives from lint `absolute_paths_not_starting_with_crate`

Fixes https://github.com/rust-lang/rust/issues/56311 (stable-to-beta regression)
-rw-r--r--src/librustc_resolve/lib.rs2
-rw-r--r--src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs11
-rw-r--r--src/test/ui/rust-2018/edition-lint-paths-2018.rs10
3 files changed, 22 insertions, 1 deletions
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 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
 
         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() {}