Skip to content

Commit e4e63bd

Browse files
committed
Account for _ in import paths
1 parent 5360e5d commit e4e63bd

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20252025
Applicability::MaybeIncorrect,
20262026
)),
20272027
)
2028+
} else if ident.is_special() {
2029+
(format!("`{ident}` is not a valid item name"), None)
20282030
} else if ident.name == sym::core {
20292031
(
20302032
format!("you might be missing a crate named `{ident}`"),

tests/ui/underscore-imports/issue-110164.stderr

+4-12
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,25 @@ error[E0432]: unresolved import `_`
3838
--> $DIR/issue-110164.rs:8:5
3939
|
4040
LL | use _::*;
41-
| ^ you might be missing a crate named `_`
42-
|
43-
= help: consider adding `extern crate _` to use the `_` crate
41+
| ^ `_` is not a valid item name
4442

4543
error[E0432]: unresolved import `_`
4644
--> $DIR/issue-110164.rs:5:5
4745
|
4846
LL | use _::a;
49-
| ^ you might be missing a crate named `_`
50-
|
51-
= help: consider adding `extern crate _` to use the `_` crate
47+
| ^ `_` is not a valid item name
5248

5349
error[E0432]: unresolved import `_`
5450
--> $DIR/issue-110164.rs:13:9
5551
|
5652
LL | use _::a;
57-
| ^ you might be missing a crate named `_`
58-
|
59-
= help: consider adding `extern crate _` to use the `_` crate
53+
| ^ `_` is not a valid item name
6054

6155
error[E0432]: unresolved import `_`
6256
--> $DIR/issue-110164.rs:16:9
6357
|
6458
LL | use _::*;
65-
| ^ you might be missing a crate named `_`
66-
|
67-
= help: consider adding `extern crate _` to use the `_` crate
59+
| ^ `_` is not a valid item name
6860

6961
error: aborting due to 10 previous errors
7062

0 commit comments

Comments
 (0)