about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-01-04 23:52:50 +0530
committerGitHub <noreply@github.com>2020-01-04 23:52:50 +0530
commit5dabc3b33987de6806af182c3d1afbb1790eaa07 (patch)
tree1bc133056f8dd8612d79334fe6a841a8313ac5ca
parent3c87772a8a4f00cfcce26615ae7808f278c61c44 (diff)
parentc818f4c88e6ef6ba83341b122901bfd390f89c8c (diff)
downloadrust-5dabc3b33987de6806af182c3d1afbb1790eaa07.tar.gz
rust-5dabc3b33987de6806af182c3d1afbb1790eaa07.zip
Rollup merge of #67775 - mental32:master, r=Dylan-DPC
Make "use $crate" a hard error

Closes #37390
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs6
-rw-r--r--src/test/ui/dollar-crate/dollar-crate-is-keyword.rs5
-rw-r--r--src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr16
-rw-r--r--src/test/ui/imports/import-crate-var.rs4
-rw-r--r--src/test/ui/imports/import-crate-var.stderr9
5 files changed, 15 insertions, 25 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 5304aced69f..3521ae0faf5 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -472,11 +472,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
 
                         self.r
                             .session
-                            .struct_span_warn(item.span, "`$crate` may not be imported")
-                            .note(
-                                "`use $crate;` was erroneously allowed and \
-                                   will become a hard error in a future release",
-                            )
+                            .struct_span_err(item.span, "`$crate` may not be imported")
                             .emit();
                     }
                 }
diff --git a/src/test/ui/dollar-crate/dollar-crate-is-keyword.rs b/src/test/ui/dollar-crate/dollar-crate-is-keyword.rs
index 6deaeb81179..d625163dc7e 100644
--- a/src/test/ui/dollar-crate/dollar-crate-is-keyword.rs
+++ b/src/test/ui/dollar-crate/dollar-crate-is-keyword.rs
@@ -6,10 +6,9 @@ macro_rules! m {
             struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate`
         }
 
-        use $crate; // OK
-                    //~^ WARN `$crate` may not be imported
+        use $crate; //~ ERROR `$crate` may not be imported
         use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate`
-                              //~^ WARN `$crate` may not be imported
+        //~^ ERROR `$crate` may not be imported
     }
 }
 
diff --git a/src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr b/src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr
index 5d4f39086ce..f5a5f13f912 100644
--- a/src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr
+++ b/src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr
@@ -8,7 +8,7 @@ LL | m!();
    | ----- in this macro invocation
 
 error: expected identifier, found reserved identifier `$crate`
-  --> $DIR/dollar-crate-is-keyword.rs:11:23
+  --> $DIR/dollar-crate-is-keyword.rs:10:23
    |
 LL |         use $crate as $crate;
    |                       ^^^^^^ expected identifier, found reserved identifier
@@ -16,27 +16,23 @@ LL |         use $crate as $crate;
 LL | m!();
    | ----- in this macro invocation
 
-warning: `$crate` may not be imported
+error: `$crate` may not be imported
   --> $DIR/dollar-crate-is-keyword.rs:9:9
    |
-LL |         use $crate; // OK
+LL |         use $crate;
    |         ^^^^^^^^^^^
 ...
 LL | m!();
    | ----- in this macro invocation
-   |
-   = note: `use $crate;` was erroneously allowed and will become a hard error in a future release
 
-warning: `$crate` may not be imported
-  --> $DIR/dollar-crate-is-keyword.rs:11:9
+error: `$crate` may not be imported
+  --> $DIR/dollar-crate-is-keyword.rs:10:9
    |
 LL |         use $crate as $crate;
    |         ^^^^^^^^^^^^^^^^^^^^^
 ...
 LL | m!();
    | ----- in this macro invocation
-   |
-   = note: `use $crate;` was erroneously allowed and will become a hard error in a future release
 
-error: aborting due to 2 previous errors
+error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/imports/import-crate-var.rs b/src/test/ui/imports/import-crate-var.rs
index b9d146d3735..aac5a15d3e6 100644
--- a/src/test/ui/imports/import-crate-var.rs
+++ b/src/test/ui/imports/import-crate-var.rs
@@ -1,10 +1,8 @@
-// check-pass
 // aux-build:import_crate_var.rs
 
 #[macro_use] extern crate import_crate_var;
 
 fn main() {
     m!();
-    //~^ WARN `$crate` may not be imported
-    //~| NOTE `use $crate;` was erroneously allowed and will become a hard error
+    //~^ ERROR `$crate` may not be imported
 }
diff --git a/src/test/ui/imports/import-crate-var.stderr b/src/test/ui/imports/import-crate-var.stderr
index 2f8c845156a..85f15ad4648 100644
--- a/src/test/ui/imports/import-crate-var.stderr
+++ b/src/test/ui/imports/import-crate-var.stderr
@@ -1,9 +1,10 @@
-warning: `$crate` may not be imported
-  --> $DIR/import-crate-var.rs:7:5
+error: `$crate` may not be imported
+  --> $DIR/import-crate-var.rs:6:5
    |
 LL |     m!();
    |     ^^^^^
    |
-   = note: `use $crate;` was erroneously allowed and will become a hard error in a future release
-   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: aborting due to previous error