]> git.lizzy.rs Git - rust.git/commitdiff
resolve: Fix false-positives from lint `absolute_paths_not_starting_with_crate`
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Wed, 28 Nov 2018 19:52:58 +0000 (22:52 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Wed, 28 Nov 2018 19:57:25 +0000 (22:57 +0300)
src/librustc_resolve/lib.rs
src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs
src/test/ui/rust-2018/edition-lint-paths-2018.rs [new file with mode: 0644]

index cbf82a80266678f72d33557103e7ab90de619c92..c1d4643c2403ea633c4d439a79c299684cb7838d 100644 (file)
@@ -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,
         };
 
index cc17a9bd6618b2e47782c3819219f4215b7acf0d..dc4ab2131a83420f9681454e854a99feca821872 100644 (file)
@@ -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 (file)
index 0000000..09b31be
--- /dev/null
@@ -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() {}