Skip to content

Commit 5dabc3b

Browse files
authored
Rollup merge of #67775 - mental32:master, r=Dylan-DPC
Make "use $crate" a hard error Closes #37390
2 parents 3c87772 + c818f4c commit 5dabc3b

File tree

5 files changed

+15
-25
lines changed

5 files changed

+15
-25
lines changed

src/librustc_resolve/build_reduced_graph.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
472472

473473
self.r
474474
.session
475-
.struct_span_warn(item.span, "`$crate` may not be imported")
476-
.note(
477-
"`use $crate;` was erroneously allowed and \
478-
will become a hard error in a future release",
479-
)
475+
.struct_span_err(item.span, "`$crate` may not be imported")
480476
.emit();
481477
}
482478
}

src/test/ui/dollar-crate/dollar-crate-is-keyword.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ macro_rules! m {
66
struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate`
77
}
88

9-
use $crate; // OK
10-
//~^ WARN `$crate` may not be imported
9+
use $crate; //~ ERROR `$crate` may not be imported
1110
use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate`
12-
//~^ WARN `$crate` may not be imported
11+
//~^ ERROR `$crate` may not be imported
1312
}
1413
}
1514

src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr

+6-10
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,31 @@ LL | m!();
88
| ----- in this macro invocation
99

1010
error: expected identifier, found reserved identifier `$crate`
11-
--> $DIR/dollar-crate-is-keyword.rs:11:23
11+
--> $DIR/dollar-crate-is-keyword.rs:10:23
1212
|
1313
LL | use $crate as $crate;
1414
| ^^^^^^ expected identifier, found reserved identifier
1515
...
1616
LL | m!();
1717
| ----- in this macro invocation
1818

19-
warning: `$crate` may not be imported
19+
error: `$crate` may not be imported
2020
--> $DIR/dollar-crate-is-keyword.rs:9:9
2121
|
22-
LL | use $crate; // OK
22+
LL | use $crate;
2323
| ^^^^^^^^^^^
2424
...
2525
LL | m!();
2626
| ----- in this macro invocation
27-
|
28-
= note: `use $crate;` was erroneously allowed and will become a hard error in a future release
2927

30-
warning: `$crate` may not be imported
31-
--> $DIR/dollar-crate-is-keyword.rs:11:9
28+
error: `$crate` may not be imported
29+
--> $DIR/dollar-crate-is-keyword.rs:10:9
3230
|
3331
LL | use $crate as $crate;
3432
| ^^^^^^^^^^^^^^^^^^^^^
3533
...
3634
LL | m!();
3735
| ----- in this macro invocation
38-
|
39-
= note: `use $crate;` was erroneously allowed and will become a hard error in a future release
4036

41-
error: aborting due to 2 previous errors
37+
error: aborting due to 4 previous errors
4238

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// check-pass
21
// aux-build:import_crate_var.rs
32

43
#[macro_use] extern crate import_crate_var;
54

65
fn main() {
76
m!();
8-
//~^ WARN `$crate` may not be imported
9-
//~| NOTE `use $crate;` was erroneously allowed and will become a hard error
7+
//~^ ERROR `$crate` may not be imported
108
}
+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
warning: `$crate` may not be imported
2-
--> $DIR/import-crate-var.rs:7:5
1+
error: `$crate` may not be imported
2+
--> $DIR/import-crate-var.rs:6:5
33
|
44
LL | m!();
55
| ^^^^^
66
|
7-
= note: `use $crate;` was erroneously allowed and will become a hard error in a future release
8-
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
7+
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
8+
9+
error: aborting due to previous error
910

0 commit comments

Comments
 (0)