diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 93db6cfc4635d..54c61708f945a 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -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}`?"), diff --git a/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr b/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr index 7de67da9b5d14..2fcad98be9f73 100644 --- a/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr +++ b/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr @@ -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; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr index e8ae7e4e36cef..c331236a4601c 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr @@ -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 diff --git a/tests/ui/simd/portable-intrinsics-arent-exposed.stderr b/tests/ui/simd/portable-intrinsics-arent-exposed.stderr index f8b3e6d65afb6..a6f27af428b51 100644 --- a/tests/ui/simd/portable-intrinsics-arent-exposed.stderr +++ b/tests/ui/simd/portable-intrinsics-arent-exposed.stderr @@ -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