From 37f4535d49e40931e793b2873cc14e9869b6b6b1 Mon Sep 17 00:00:00 2001 From: mental Date: Wed, 1 Jan 2020 14:33:53 +0200 Subject: [PATCH 1/8] Make use $crate a hard error --- src/librustc_resolve/build_reduced_graph.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 911de5d2174e6..b563e6e14e8f8 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -472,12 +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", - ) - .emit(); + .struct_span_err(item.span, "`$crate` may not be imported"); } } From 72ee3622d77c21bf84d2324f638f8d7911398923 Mon Sep 17 00:00:00 2001 From: mental Date: Wed, 1 Jan 2020 14:44:19 +0200 Subject: [PATCH 2/8] Forgot an .emit() --- src/librustc_resolve/build_reduced_graph.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index b563e6e14e8f8..64e0a27c5848c 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -472,7 +472,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { self.r .session - .struct_span_err(item.span, "`$crate` may not be imported"); + .struct_span_err(item.span, "`$crate` may not be imported") + .emit(); } } From 3323f1e57d64e98da05dcc90b56e0f2cde89653e Mon Sep 17 00:00:00 2001 From: mental Date: Thu, 2 Jan 2020 08:38:59 +0200 Subject: [PATCH 3/8] Update src/test/ui --- .../ui/dollar-crate/dollar-crate-is-keyword.rs | 4 +--- .../dollar-crate/dollar-crate-is-keyword.stderr | 16 ++++++---------- src/test/ui/imports/import-crate-var.rs | 3 +-- src/test/ui/imports/import-crate-var.stderr | 3 +-- 4 files changed, 9 insertions(+), 17 deletions(-) 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 6deaeb8117956..318c4c3974bb2 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,8 @@ 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 } } 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 5d4f39086cee6..6f3cf9a55c744 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; // ERROR `$crate` may not be imported | ^^^^^^^^^^^ ... 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 b9d146d3735f2..ad1c34844619a 100644 --- a/src/test/ui/imports/import-crate-var.rs +++ b/src/test/ui/imports/import-crate-var.rs @@ -5,6 +5,5 @@ 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 2f8c845156a82..98f113fb4559f 100644 --- a/src/test/ui/imports/import-crate-var.stderr +++ b/src/test/ui/imports/import-crate-var.stderr @@ -1,9 +1,8 @@ -warning: `$crate` may not be imported +error: `$crate` may not be imported --> $DIR/import-crate-var.rs:7: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) From 56b3120bf487ac6197a5af8dd8e446de98b047a8 Mon Sep 17 00:00:00 2001 From: mental Date: Thu, 2 Jan 2020 11:59:32 +0200 Subject: [PATCH 4/8] Remove // check-pass for ui/import/import-crate-var.rs --- src/test/ui/imports/import-crate-var.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/ui/imports/import-crate-var.rs b/src/test/ui/imports/import-crate-var.rs index ad1c34844619a..aac5a15d3e6b5 100644 --- a/src/test/ui/imports/import-crate-var.rs +++ b/src/test/ui/imports/import-crate-var.rs @@ -1,4 +1,3 @@ -// check-pass // aux-build:import_crate_var.rs #[macro_use] extern crate import_crate_var; From b97438333e4b1b73a650cf2b25ebbe4ba5c3a618 Mon Sep 17 00:00:00 2001 From: mental Date: Thu, 2 Jan 2020 12:03:04 +0200 Subject: [PATCH 5/8] Lets see if I can get these ui tests to run. --- src/test/ui/dollar-crate/dollar-crate-is-keyword.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 318c4c3974bb2..e1a8eda948edb 100644 --- a/src/test/ui/dollar-crate/dollar-crate-is-keyword.rs +++ b/src/test/ui/dollar-crate/dollar-crate-is-keyword.rs @@ -6,7 +6,7 @@ macro_rules! m { struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate` } - use $crate; // ERROR `$crate` may not be imported + use $crate; //~ ERROR `$crate` may not be imported use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate` } } From c0da63951afb127a898a503b5e80061f8aa93105 Mon Sep 17 00:00:00 2001 From: mental Date: Fri, 3 Jan 2020 11:50:12 +0200 Subject: [PATCH 6/8] Thank you Dylan and JohnTitor for blessing me. --- src/test/ui/dollar-crate/dollar-crate-is-keyword.rs | 1 + src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr | 3 +-- src/test/ui/imports/import-crate-var.stderr | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) 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 e1a8eda948edb..d625163dc7e1c 100644 --- a/src/test/ui/dollar-crate/dollar-crate-is-keyword.rs +++ b/src/test/ui/dollar-crate/dollar-crate-is-keyword.rs @@ -8,6 +8,7 @@ macro_rules! m { use $crate; //~ ERROR `$crate` may not be imported use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate` + //~^ 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 6f3cf9a55c744..1efd3fa06a542 100644 --- a/src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr +++ b/src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr @@ -19,7 +19,7 @@ LL | m!(); error: `$crate` may not be imported --> $DIR/dollar-crate-is-keyword.rs:9:9 | -LL | use $crate; // ERROR `$crate` may not be imported +LL | use $crate; | ^^^^^^^^^^^ ... LL | m!(); @@ -35,4 +35,3 @@ LL | m!(); | ----- in this macro invocation error: aborting due to 4 previous errors - diff --git a/src/test/ui/imports/import-crate-var.stderr b/src/test/ui/imports/import-crate-var.stderr index 98f113fb4559f..4f98e973c52a6 100644 --- a/src/test/ui/imports/import-crate-var.stderr +++ b/src/test/ui/imports/import-crate-var.stderr @@ -1,8 +1,9 @@ error: `$crate` may not be imported - --> $DIR/import-crate-var.rs:7:5 + --> $DIR/import-crate-var.rs:6:5 | LL | m!(); | ^^^^^ | - = 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 From 5b7134a30e2788912cf230887cf7b2fc68711b71 Mon Sep 17 00:00:00 2001 From: mental Date: Fri, 3 Jan 2020 17:48:10 +0200 Subject: [PATCH 7/8] Apply suggestions from code review Co-Authored-By: Yuki Okushi From c818f4c88e6ef6ba83341b122901bfd390f89c8c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 3 Jan 2020 18:25:49 +0900 Subject: [PATCH 8/8] try to fix ui errors --- src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr | 1 + src/test/ui/imports/import-crate-var.stderr | 1 + 2 files changed, 2 insertions(+) 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 1efd3fa06a542..f5a5f13f9121e 100644 --- a/src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr +++ b/src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr @@ -35,3 +35,4 @@ LL | m!(); | ----- in this macro invocation error: aborting due to 4 previous errors + diff --git a/src/test/ui/imports/import-crate-var.stderr b/src/test/ui/imports/import-crate-var.stderr index 4f98e973c52a6..85f15ad4648a7 100644 --- a/src/test/ui/imports/import-crate-var.stderr +++ b/src/test/ui/imports/import-crate-var.stderr @@ -7,3 +7,4 @@ LL | m!(); = 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 +