Skip to content

Commit 360bafa

Browse files
committed
Auto merge of #118065 - estebank:core-not-found-404, r=TaKO8Ki
When failing to import `core`, suggest `std`
2 parents c387f01 + ec50f1c commit 360bafa

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18581858
Applicability::MaybeIncorrect,
18591859
)),
18601860
)
1861+
} else if ident.name == sym::core {
1862+
(
1863+
format!("maybe a missing crate `{ident}`?"),
1864+
Some((
1865+
vec![(ident.span, "std".to_string())],
1866+
"try using `std` instead of `core`".to_string(),
1867+
Applicability::MaybeIncorrect,
1868+
)),
1869+
)
18611870
} else if self.tcx.sess.is_rust_2015() {
18621871
(
18631872
format!("maybe a missing crate `{ident}`?"),

tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ error[E0432]: unresolved import `core`
22
--> $DIR/feature-gate-extern_absolute_paths.rs:1:5
33
|
44
LL | use core::default;
5-
| ^^^^ maybe a missing crate `core`?
6-
|
7-
= help: consider adding `extern crate core` to use the `core` crate
5+
| ^^^^
6+
| |
7+
| maybe a missing crate `core`?
8+
| help: try using `std` instead of `core`: `std`
89

910
error[E0433]: failed to resolve: maybe a missing crate `core`?
1011
--> $DIR/feature-gate-extern_absolute_paths.rs:4:19
1112
|
1213
LL | let _: u8 = ::core::default::Default();
1314
| ^^^^ maybe a missing crate `core`?
1415
|
15-
= help: consider adding `extern crate core` to use the `core` crate
16+
help: try using `std` instead of `core`
17+
|
18+
LL | let _: u8 = ::std::default::Default();
19+
| ~~~
1620
help: consider importing this module
1721
|
1822
LL + use std::default;

tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ error[E0433]: failed to resolve: maybe a missing crate `core`?
22
--> $DIR/issue-102156.rs:4:5
33
|
44
LL | use core::convert::{From, TryFrom};
5-
| ^^^^ maybe a missing crate `core`?
6-
|
7-
= help: consider adding `extern crate core` to use the `core` crate
5+
| ^^^^
6+
| |
7+
| maybe a missing crate `core`?
8+
| help: try using `std` instead of `core`: `std`
89

910
error[E0433]: failed to resolve: maybe a missing crate `core`?
1011
--> $DIR/issue-102156.rs:4:5
1112
|
1213
LL | use core::convert::{From, TryFrom};
13-
| ^^^^ maybe a missing crate `core`?
14+
| ^^^^
15+
| |
16+
| maybe a missing crate `core`?
17+
| help: try using `std` instead of `core`: `std`
1418
|
15-
= help: consider adding `extern crate core` to use the `core` crate
1619
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1720

1821
error: aborting due to 2 previous errors

tests/ui/simd/portable-intrinsics-arent-exposed.stderr

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ error[E0433]: failed to resolve: maybe a missing crate `core`?
22
--> $DIR/portable-intrinsics-arent-exposed.rs:4:5
33
|
44
LL | use core::simd::intrinsics;
5-
| ^^^^ maybe a missing crate `core`?
6-
|
7-
= help: consider adding `extern crate core` to use the `core` crate
5+
| ^^^^
6+
| |
7+
| maybe a missing crate `core`?
8+
| help: try using `std` instead of `core`: `std`
89

910
error[E0432]: unresolved import `std::simd::intrinsics`
1011
--> $DIR/portable-intrinsics-arent-exposed.rs:5:5

0 commit comments

Comments
 (0)