Auto merge of #118065 - estebank:core-not-found-404, r=TaKO8Ki

When failing to import `core`, suggest `std`
This commit is contained in:
bors 2023-11-23 02:26:52 +00:00
commit 360bafad68
4 changed files with 29 additions and 12 deletions

View File

@ -1858,6 +1858,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
Applicability::MaybeIncorrect,
)),
)
} else if ident.name == sym::core {
(
format!("maybe a missing crate `{ident}`?"),
Some((
vec![(ident.span, "std".to_string())],
"try using `std` instead of `core`".to_string(),
Applicability::MaybeIncorrect,
)),
)
} else if self.tcx.sess.is_rust_2015() {
(
format!("maybe a missing crate `{ident}`?"),

View File

@ -2,9 +2,10 @@ error[E0432]: unresolved import `core`
--> $DIR/feature-gate-extern_absolute_paths.rs:1:5
|
LL | use core::default;
| ^^^^ maybe a missing crate `core`?
|
= help: consider adding `extern crate core` to use the `core` crate
| ^^^^
| |
| maybe a missing crate `core`?
| help: try using `std` instead of `core`: `std`
error[E0433]: failed to resolve: maybe a missing crate `core`?
--> $DIR/feature-gate-extern_absolute_paths.rs:4:19
@ -12,7 +13,10 @@ error[E0433]: failed to resolve: maybe a missing crate `core`?
LL | let _: u8 = ::core::default::Default();
| ^^^^ maybe a missing crate `core`?
|
= help: consider adding `extern crate core` to use the `core` crate
help: try using `std` instead of `core`
|
LL | let _: u8 = ::std::default::Default();
| ~~~
help: consider importing this module
|
LL + use std::default;

View File

@ -2,17 +2,20 @@ error[E0433]: failed to resolve: maybe a missing crate `core`?
--> $DIR/issue-102156.rs:4:5
|
LL | use core::convert::{From, TryFrom};
| ^^^^ maybe a missing crate `core`?
|
= help: consider adding `extern crate core` to use the `core` crate
| ^^^^
| |
| maybe a missing crate `core`?
| help: try using `std` instead of `core`: `std`
error[E0433]: failed to resolve: maybe a missing crate `core`?
--> $DIR/issue-102156.rs:4:5
|
LL | use core::convert::{From, TryFrom};
| ^^^^ maybe a missing crate `core`?
| ^^^^
| |
| maybe a missing crate `core`?
| help: try using `std` instead of `core`: `std`
|
= help: consider adding `extern crate core` to use the `core` crate
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors

View File

@ -2,9 +2,10 @@ error[E0433]: failed to resolve: maybe a missing crate `core`?
--> $DIR/portable-intrinsics-arent-exposed.rs:4:5
|
LL | use core::simd::intrinsics;
| ^^^^ maybe a missing crate `core`?
|
= help: consider adding `extern crate core` to use the `core` crate
| ^^^^
| |
| maybe a missing crate `core`?
| help: try using `std` instead of `core`: `std`
error[E0432]: unresolved import `std::simd::intrinsics`
--> $DIR/portable-intrinsics-arent-exposed.rs:5:5