From 3aefa86a86adb4aaff1866d3ac422a036ed8cd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 18 Nov 2024 04:02:32 +0000 Subject: [PATCH] Add `help` for potentially missing crate in `Cargo.toml` On resolve errors where there might be a missing crate, mention `cargo add foo`: ``` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:4:11 | LL | impl From for Error { | ^^^^ use of unresolved module or unlinked crate `nope` | = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml` ``` --- compiler/rustc_resolve/src/diagnostics.rs | 14 ++++++++++++-- .../rustdoc-ui/ice-unresolved-import-100241.stderr | 2 +- .../intra-doc/unresolved-import-recovery.stderr | 2 +- tests/rustdoc-ui/issues/issue-61732.stderr | 2 +- .../field-attributes-vis-unresolved.stderr | 4 ++-- .../ui/coherence/conflicting-impl-with-err.stderr | 4 ++++ tests/ui/delegation/bad-resolve.stderr | 2 ++ tests/ui/error-codes/E0432.stderr | 2 +- tests/ui/extern-flag/multiple-opts.stderr | 2 ++ tests/ui/extern-flag/noprelude.stderr | 2 ++ tests/ui/foreign/stashed-issue-121451.stderr | 2 ++ .../extern-prelude-from-opaque-fail-2018.stderr | 2 ++ .../hygiene/extern-prelude-from-opaque-fail.stderr | 2 ++ tests/ui/impl-trait/issue-72911.stderr | 4 ++++ .../ui/impl-trait/stashed-diag-issue-121504.stderr | 2 ++ tests/ui/imports/import-from-missing-star-2.stderr | 2 +- tests/ui/imports/import-from-missing-star-3.stderr | 4 ++-- tests/ui/imports/import-from-missing-star.stderr | 2 +- tests/ui/imports/import3.stderr | 2 +- tests/ui/imports/issue-109343.stderr | 2 +- tests/ui/imports/issue-1697.rs | 2 +- tests/ui/imports/issue-1697.stderr | 2 +- tests/ui/imports/issue-33464.stderr | 6 +++--- tests/ui/imports/issue-36881.stderr | 2 +- tests/ui/imports/issue-37887.stderr | 2 +- tests/ui/imports/issue-53269.stderr | 2 +- tests/ui/imports/issue-55457.stderr | 2 +- tests/ui/imports/issue-81413.stderr | 2 +- tests/ui/imports/tool-mod-child.stderr | 8 ++++---- tests/ui/imports/unresolved-imports-used.stderr | 8 ++++---- tests/ui/issues/issue-33293.stderr | 2 ++ .../extern/keyword-extern-as-identifier-use.stderr | 2 +- .../ui/macros/builtin-prelude-no-accidents.stderr | 3 +++ tests/ui/macros/macro_path_as_generic_bound.stderr | 2 ++ tests/ui/mir/issue-121103.stderr | 4 ++++ .../mod_file_disambig.stderr | 2 ++ ...const-param-decl-on-type-instead-of-impl.stderr | 2 ++ tests/ui/parser/dyn-trait-compatibility.stderr | 2 ++ tests/ui/parser/mod_file_not_exist.rs | 1 + tests/ui/parser/mod_file_not_exist.stderr | 2 ++ tests/ui/privacy/restricted/test.stderr | 2 +- tests/ui/resolve/112590-2.stderr | 4 ++++ tests/ui/resolve/bad-module.stderr | 4 ++++ tests/ui/resolve/editions-crate-root-2015.stderr | 4 ++-- .../ui/resolve/export-fully-qualified-2018.stderr | 2 ++ tests/ui/resolve/export-fully-qualified.stderr | 2 ++ tests/ui/resolve/extern-prelude-fail.stderr | 4 ++-- tests/ui/resolve/issue-101749-2.stderr | 2 ++ tests/ui/resolve/issue-101749.stderr | 1 + tests/ui/resolve/issue-82865.stderr | 2 +- tests/ui/resolve/resolve-bad-visibility.stderr | 4 ++-- .../non-existent-1.stderr | 2 ++ .../rust-2018/unresolved-asterisk-imports.stderr | 2 ++ .../suggestions/issue-112590-suggest-import.stderr | 3 +++ tests/ui/typeck/issue-120856.stderr | 4 ++++ .../path-to-method-sugg-unresolved-expr.stderr | 2 ++ .../unresolved/unresolved-asterisk-imports.stderr | 2 +- tests/ui/unresolved/unresolved-import.rs | 2 +- tests/ui/unresolved/unresolved-import.stderr | 2 +- 59 files changed, 124 insertions(+), 44 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 59dcb0abb281..7caea0ea79a3 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -811,7 +811,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } err.multipart_suggestion(msg, suggestions, applicability); } - if let Some(ModuleOrUniformRoot::Module(module)) = module && let Some(module) = module.opt_def_id() && let Some(segment) = segment @@ -2037,7 +2036,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.current_crate_outer_attr_insert_span, format!("extern crate {ident};\n"), )], - format!("consider importing the `{ident}` crate"), + format!( + "if you wanted to use a crate named `{ident}`, use `cargo add {ident}` \ + to add it to your `Cargo.toml` and import it in your code", + ), Applicability::MaybeIncorrect, )), ) @@ -2216,6 +2218,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let descr = binding.res().descr(); (format!("{descr} `{ident}` is not a crate or module"), suggestion) } else { + let suggestion = suggestion.or(Some(( + vec![], + format!( + "if you wanted to use a crate named `{ident}`, use `cargo add {ident}` to \ + add it to your `Cargo.toml`", + ), + Applicability::MaybeIncorrect, + ))); (format!("use of unresolved module or unlinked crate `{ident}`"), suggestion) } } diff --git a/tests/rustdoc-ui/ice-unresolved-import-100241.stderr b/tests/rustdoc-ui/ice-unresolved-import-100241.stderr index 4319c90e8ae3..9440a896a08e 100644 --- a/tests/rustdoc-ui/ice-unresolved-import-100241.stderr +++ b/tests/rustdoc-ui/ice-unresolved-import-100241.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `inner` LL | pub use inner::S; | ^^^^^ use of unresolved module or unlinked crate `inner` | -help: consider importing the `inner` crate +help: if you wanted to use a crate named `inner`, use `cargo add inner` to add it to your `Cargo.toml` and import it in your code | LL + extern crate inner; | diff --git a/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr b/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr index 32337a831442..ea935560aef7 100644 --- a/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr +++ b/tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `unr LL | use unresolved_crate::module::Name; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved_crate` | -help: consider importing the `unresolved_crate` crate +help: if you wanted to use a crate named `unresolved_crate`, use `cargo add unresolved_crate` to add it to your `Cargo.toml` and import it in your code | LL + extern crate unresolved_crate; | diff --git a/tests/rustdoc-ui/issues/issue-61732.stderr b/tests/rustdoc-ui/issues/issue-61732.stderr index aa8b6071b4a0..ed1c8d718575 100644 --- a/tests/rustdoc-ui/issues/issue-61732.stderr +++ b/tests/rustdoc-ui/issues/issue-61732.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `r#m LL | pub(in crate::r#mod) fn main() {} | ^^^^^ use of unresolved module or unlinked crate `r#mod` | -help: consider importing the `r#mod` crate +help: if you wanted to use a crate named `r#mod`, use `cargo add r#mod` to add it to your `Cargo.toml` and import it in your code | LL + extern crate r#mod; | diff --git a/tests/ui/attributes/field-attributes-vis-unresolved.stderr b/tests/ui/attributes/field-attributes-vis-unresolved.stderr index e4b324914bc4..f4abe8e81353 100644 --- a/tests/ui/attributes/field-attributes-vis-unresolved.stderr +++ b/tests/ui/attributes/field-attributes-vis-unresolved.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `non LL | pub(in nonexistent) field: u8 | ^^^^^^^^^^^ use of unresolved module or unlinked crate `nonexistent` | -help: consider importing the `nonexistent` crate +help: if you wanted to use a crate named `nonexistent`, use `cargo add nonexistent` to add it to your `Cargo.toml` and import it in your code | LL + extern crate nonexistent; | @@ -15,7 +15,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `non LL | pub(in nonexistent) u8 | ^^^^^^^^^^^ use of unresolved module or unlinked crate `nonexistent` | -help: consider importing the `nonexistent` crate +help: if you wanted to use a crate named `nonexistent`, use `cargo add nonexistent` to add it to your `Cargo.toml` and import it in your code | LL + extern crate nonexistent; | diff --git a/tests/ui/coherence/conflicting-impl-with-err.stderr b/tests/ui/coherence/conflicting-impl-with-err.stderr index 0dd62566111b..ce03b3ed0ba9 100644 --- a/tests/ui/coherence/conflicting-impl-with-err.stderr +++ b/tests/ui/coherence/conflicting-impl-with-err.stderr @@ -3,12 +3,16 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nop | LL | impl From for Error { | ^^^^ use of unresolved module or unlinked crate `nope` + | + = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:5:16 | LL | fn from(_: nope::Thing) -> Self { | ^^^^ use of unresolved module or unlinked crate `nope` + | + = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml` error: aborting due to 2 previous errors diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr index 332da17733fd..c5347178de94 100644 --- a/tests/ui/delegation/bad-resolve.stderr +++ b/tests/ui/delegation/bad-resolve.stderr @@ -86,6 +86,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `unr | LL | reuse unresolved_prefix::{a, b, c}; | ^^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved_prefix` + | + = help: if you wanted to use a crate named `unresolved_prefix`, use `cargo add unresolved_prefix` to add it to your `Cargo.toml` error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/bad-resolve.rs:44:29 diff --git a/tests/ui/error-codes/E0432.stderr b/tests/ui/error-codes/E0432.stderr index a1bcade3aa34..806228e918c9 100644 --- a/tests/ui/error-codes/E0432.stderr +++ b/tests/ui/error-codes/E0432.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `something` LL | use something::Foo; | ^^^^^^^^^ use of unresolved module or unlinked crate `something` | -help: consider importing the `something` crate +help: if you wanted to use a crate named `something`, use `cargo add something` to add it to your `Cargo.toml` and import it in your code | LL + extern crate something; | diff --git a/tests/ui/extern-flag/multiple-opts.stderr b/tests/ui/extern-flag/multiple-opts.stderr index 521f9fe49c78..bb235b8053a8 100644 --- a/tests/ui/extern-flag/multiple-opts.stderr +++ b/tests/ui/extern-flag/multiple-opts.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `som | LL | somedep::somefun(); | ^^^^^^^ use of unresolved module or unlinked crate `somedep` + | + = help: if you wanted to use a crate named `somedep`, use `cargo add somedep` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/extern-flag/noprelude.stderr b/tests/ui/extern-flag/noprelude.stderr index f9291b45ebe4..1c572cbf6222 100644 --- a/tests/ui/extern-flag/noprelude.stderr +++ b/tests/ui/extern-flag/noprelude.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `som | LL | somedep::somefun(); | ^^^^^^^ use of unresolved module or unlinked crate `somedep` + | + = help: if you wanted to use a crate named `somedep`, use `cargo add somedep` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/foreign/stashed-issue-121451.stderr b/tests/ui/foreign/stashed-issue-121451.stderr index e3939f7fb43c..a4bf26c14e79 100644 --- a/tests/ui/foreign/stashed-issue-121451.stderr +++ b/tests/ui/foreign/stashed-issue-121451.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `lib | LL | extern "C" fn _f() -> libc::uintptr_t {} | ^^^^ use of unresolved module or unlinked crate `libc` + | + = help: if you wanted to use a crate named `libc`, use `cargo add libc` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr index 1b4cae302831..b571a53d5353 100644 --- a/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr @@ -24,6 +24,7 @@ LL | fn f() { my_core::mem::drop(0); } LL | a!(); | ---- in this macro invocation | + = help: if you wanted to use a crate named `my_core`, use `cargo add my_core` to add it to your `Cargo.toml` = help: consider importing this module: std::mem = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -34,6 +35,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `my_ LL | fn f() { my_core::mem::drop(0); } | ^^^^^^^ use of unresolved module or unlinked crate `my_core` | + = help: if you wanted to use a crate named `my_core`, use `cargo add my_core` to add it to your `Cargo.toml` help: consider importing this module | LL + use std::mem; diff --git a/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr b/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr index be2f15610779..e2a63b1061dc 100644 --- a/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr +++ b/tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr @@ -24,6 +24,7 @@ LL | fn f() { my_core::mem::drop(0); } LL | a!(); | ---- in this macro invocation | + = help: if you wanted to use a crate named `my_core`, use `cargo add my_core` to add it to your `Cargo.toml` = help: consider importing this module: my_core::mem = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -34,6 +35,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `my_ LL | fn f() { my_core::mem::drop(0); } | ^^^^^^^ use of unresolved module or unlinked crate `my_core` | + = help: if you wanted to use a crate named `my_core`, use `cargo add my_core` to add it to your `Cargo.toml` help: consider importing this module | LL + use my_core::mem; diff --git a/tests/ui/impl-trait/issue-72911.stderr b/tests/ui/impl-trait/issue-72911.stderr index b166334cc6f7..cc78e14bfc14 100644 --- a/tests/ui/impl-trait/issue-72911.stderr +++ b/tests/ui/impl-trait/issue-72911.stderr @@ -3,12 +3,16 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo | LL | fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator { | ^^^ use of unresolved module or unlinked crate `foo` + | + = help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo` --> $DIR/issue-72911.rs:16:41 | LL | fn lint_files() -> impl Iterator { | ^^^ use of unresolved module or unlinked crate `foo` + | + = help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml` error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/stashed-diag-issue-121504.stderr b/tests/ui/impl-trait/stashed-diag-issue-121504.stderr index bfebe5eb4d89..ed34881cca94 100644 --- a/tests/ui/impl-trait/stashed-diag-issue-121504.stderr +++ b/tests/ui/impl-trait/stashed-diag-issue-121504.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `xyz | LL | impl MyTrait for xyz::T { | ^^^ use of unresolved module or unlinked crate `xyz` + | + = help: if you wanted to use a crate named `xyz`, use `cargo add xyz` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/imports/import-from-missing-star-2.stderr b/tests/ui/imports/import-from-missing-star-2.stderr index aa84b5d711e4..d2952726a1bc 100644 --- a/tests/ui/imports/import-from-missing-star-2.stderr +++ b/tests/ui/imports/import-from-missing-star-2.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `spam` LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` | -help: consider importing the `spam` crate +help: if you wanted to use a crate named `spam`, use `cargo add spam` to add it to your `Cargo.toml` and import it in your code | LL + extern crate spam; | diff --git a/tests/ui/imports/import-from-missing-star-3.stderr b/tests/ui/imports/import-from-missing-star-3.stderr index ca2c9270b6bd..3fc68ed6a4c8 100644 --- a/tests/ui/imports/import-from-missing-star-3.stderr +++ b/tests/ui/imports/import-from-missing-star-3.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `spam` LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` | -help: consider importing the `spam` crate +help: if you wanted to use a crate named `spam`, use `cargo add spam` to add it to your `Cargo.toml` and import it in your code | LL + extern crate spam; | @@ -15,7 +15,7 @@ error[E0432]: unresolved import `spam` LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` | -help: consider importing the `spam` crate +help: if you wanted to use a crate named `spam`, use `cargo add spam` to add it to your `Cargo.toml` and import it in your code | LL + extern crate spam; | diff --git a/tests/ui/imports/import-from-missing-star.stderr b/tests/ui/imports/import-from-missing-star.stderr index ac5508b002bd..899cfda426bd 100644 --- a/tests/ui/imports/import-from-missing-star.stderr +++ b/tests/ui/imports/import-from-missing-star.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `spam` LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` | -help: consider importing the `spam` crate +help: if you wanted to use a crate named `spam`, use `cargo add spam` to add it to your `Cargo.toml` and import it in your code | LL + extern crate spam; | diff --git a/tests/ui/imports/import3.stderr b/tests/ui/imports/import3.stderr index eed065023a28..a02d25b1ca48 100644 --- a/tests/ui/imports/import3.stderr +++ b/tests/ui/imports/import3.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `main` LL | use main::bar; | ^^^^ use of unresolved module or unlinked crate `main` | -help: consider importing the `main` crate +help: if you wanted to use a crate named `main`, use `cargo add main` to add it to your `Cargo.toml` and import it in your code | LL + extern crate main; | diff --git a/tests/ui/imports/issue-109343.stderr b/tests/ui/imports/issue-109343.stderr index 346fe66d90f9..01f61301c883 100644 --- a/tests/ui/imports/issue-109343.stderr +++ b/tests/ui/imports/issue-109343.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `unresolved` LL | pub use unresolved::f; | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` | -help: consider importing the `unresolved` crate +help: if you wanted to use a crate named `unresolved`, use `cargo add unresolved` to add it to your `Cargo.toml` and import it in your code | LL + extern crate unresolved; | diff --git a/tests/ui/imports/issue-1697.rs b/tests/ui/imports/issue-1697.rs index 0545056ffbb5..f9f846a36c28 100644 --- a/tests/ui/imports/issue-1697.rs +++ b/tests/ui/imports/issue-1697.rs @@ -3,6 +3,6 @@ use unresolved::*; //~^ ERROR unresolved import `unresolved` [E0432] //~| NOTE use of unresolved module or unlinked crate `unresolved` -//~| HELP consider importing the `unresolved` crate +//~| HELP if you wanted to use a crate named `unresolved`, use `cargo add unresolved` to add it to your `Cargo.toml` fn main() {} diff --git a/tests/ui/imports/issue-1697.stderr b/tests/ui/imports/issue-1697.stderr index a3d37f0703f7..a55b699be850 100644 --- a/tests/ui/imports/issue-1697.stderr +++ b/tests/ui/imports/issue-1697.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `unresolved` LL | use unresolved::*; | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` | -help: consider importing the `unresolved` crate +help: if you wanted to use a crate named `unresolved`, use `cargo add unresolved` to add it to your `Cargo.toml` and import it in your code | LL + extern crate unresolved; | diff --git a/tests/ui/imports/issue-33464.stderr b/tests/ui/imports/issue-33464.stderr index 45bb42489304..30c5a66db7ef 100644 --- a/tests/ui/imports/issue-33464.stderr +++ b/tests/ui/imports/issue-33464.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `abc` LL | use abc::one_el; | ^^^ use of unresolved module or unlinked crate `abc` | -help: consider importing the `abc` crate +help: if you wanted to use a crate named `abc`, use `cargo add abc` to add it to your `Cargo.toml` and import it in your code | LL + extern crate abc; | @@ -15,7 +15,7 @@ error[E0432]: unresolved import `abc` LL | use abc::{a, bbb, cccccc}; | ^^^ use of unresolved module or unlinked crate `abc` | -help: consider importing the `abc` crate +help: if you wanted to use a crate named `abc`, use `cargo add abc` to add it to your `Cargo.toml` and import it in your code | LL + extern crate abc; | @@ -26,7 +26,7 @@ error[E0432]: unresolved import `a_very_long_name` LL | use a_very_long_name::{el, el2}; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `a_very_long_name` | -help: consider importing the `a_very_long_name` crate +help: if you wanted to use a crate named `a_very_long_name`, use `cargo add a_very_long_name` to add it to your `Cargo.toml` and import it in your code | LL + extern crate a_very_long_name; | diff --git a/tests/ui/imports/issue-36881.stderr b/tests/ui/imports/issue-36881.stderr index bc3759dd83a7..4d7585c6514b 100644 --- a/tests/ui/imports/issue-36881.stderr +++ b/tests/ui/imports/issue-36881.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `issue_36881_aux` LL | use issue_36881_aux::Foo; | ^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `issue_36881_aux` | -help: consider importing the `issue_36881_aux` crate +help: if you wanted to use a crate named `issue_36881_aux`, use `cargo add issue_36881_aux` to add it to your `Cargo.toml` and import it in your code | LL + extern crate issue_36881_aux; | diff --git a/tests/ui/imports/issue-37887.stderr b/tests/ui/imports/issue-37887.stderr index 516149b42170..9b79a058a080 100644 --- a/tests/ui/imports/issue-37887.stderr +++ b/tests/ui/imports/issue-37887.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `test` LL | use test::*; | ^^^^ use of unresolved module or unlinked crate `test` | -help: consider importing the `test` crate +help: if you wanted to use a crate named `test`, use `cargo add test` to add it to your `Cargo.toml` and import it in your code | LL + extern crate test; | diff --git a/tests/ui/imports/issue-53269.stderr b/tests/ui/imports/issue-53269.stderr index 37087ae2b8ae..a008518a11fc 100644 --- a/tests/ui/imports/issue-53269.stderr +++ b/tests/ui/imports/issue-53269.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `nonexistent_module` LL | use nonexistent_module::mac; | ^^^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `nonexistent_module` | -help: consider importing the `nonexistent_module` crate +help: if you wanted to use a crate named `nonexistent_module`, use `cargo add nonexistent_module` to add it to your `Cargo.toml` and import it in your code | LL + extern crate nonexistent_module; | diff --git a/tests/ui/imports/issue-55457.stderr b/tests/ui/imports/issue-55457.stderr index dcc9447ecfbb..b10c7587057b 100644 --- a/tests/ui/imports/issue-55457.stderr +++ b/tests/ui/imports/issue-55457.stderr @@ -13,7 +13,7 @@ error[E0432]: unresolved import `non_existent` LL | use non_existent::non_existent; | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `non_existent` | -help: consider importing the `non_existent` crate +help: if you wanted to use a crate named `non_existent`, use `cargo add non_existent` to add it to your `Cargo.toml` and import it in your code | LL + extern crate non_existent; | diff --git a/tests/ui/imports/issue-81413.stderr b/tests/ui/imports/issue-81413.stderr index 647816798c18..2cc88255b91c 100644 --- a/tests/ui/imports/issue-81413.stderr +++ b/tests/ui/imports/issue-81413.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `doesnt_exist` LL | pub use doesnt_exist::*; | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `doesnt_exist` | -help: consider importing the `doesnt_exist` crate +help: if you wanted to use a crate named `doesnt_exist`, use `cargo add doesnt_exist` to add it to your `Cargo.toml` and import it in your code | LL + extern crate doesnt_exist; | diff --git a/tests/ui/imports/tool-mod-child.stderr b/tests/ui/imports/tool-mod-child.stderr index 718c42ebb473..f70108923bcc 100644 --- a/tests/ui/imports/tool-mod-child.stderr +++ b/tests/ui/imports/tool-mod-child.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `cli LL | use clippy::a::b; | ^^^^^^ use of unresolved module or unlinked crate `clippy` | -help: consider importing the `clippy` crate +help: if you wanted to use a crate named `clippy`, use `cargo add clippy` to add it to your `Cargo.toml` and import it in your code | LL + extern crate clippy; | @@ -15,7 +15,7 @@ error[E0432]: unresolved import `clippy` LL | use clippy::a; | ^^^^^^ use of unresolved module or unlinked crate `clippy` | -help: consider importing the `clippy` crate +help: if you wanted to use a crate named `clippy`, use `cargo add clippy` to add it to your `Cargo.toml` and import it in your code | LL + extern crate clippy; | @@ -26,7 +26,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `rus LL | use rustdoc::a::b; | ^^^^^^^ use of unresolved module or unlinked crate `rustdoc` | -help: consider importing the `rustdoc` crate +help: if you wanted to use a crate named `rustdoc`, use `cargo add rustdoc` to add it to your `Cargo.toml` and import it in your code | LL + extern crate rustdoc; | @@ -37,7 +37,7 @@ error[E0432]: unresolved import `rustdoc` LL | use rustdoc::a; | ^^^^^^^ use of unresolved module or unlinked crate `rustdoc` | -help: consider importing the `rustdoc` crate +help: if you wanted to use a crate named `rustdoc`, use `cargo add rustdoc` to add it to your `Cargo.toml` and import it in your code | LL + extern crate rustdoc; | diff --git a/tests/ui/imports/unresolved-imports-used.stderr b/tests/ui/imports/unresolved-imports-used.stderr index aeb67947720d..eafaba29d5bf 100644 --- a/tests/ui/imports/unresolved-imports-used.stderr +++ b/tests/ui/imports/unresolved-imports-used.stderr @@ -16,7 +16,7 @@ error[E0432]: unresolved import `foo` LL | use foo::bar; | ^^^ use of unresolved module or unlinked crate `foo` | -help: consider importing the `foo` crate +help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml` and import it in your code | LL + extern crate foo; | @@ -27,7 +27,7 @@ error[E0432]: unresolved import `baz` LL | use baz::*; | ^^^ use of unresolved module or unlinked crate `baz` | -help: consider importing the `baz` crate +help: if you wanted to use a crate named `baz`, use `cargo add baz` to add it to your `Cargo.toml` and import it in your code | LL + extern crate baz; | @@ -38,7 +38,7 @@ error[E0432]: unresolved import `foo2` LL | use foo2::bar2; | ^^^^ use of unresolved module or unlinked crate `foo2` | -help: consider importing the `foo2` crate +help: if you wanted to use a crate named `foo2`, use `cargo add foo2` to add it to your `Cargo.toml` and import it in your code | LL + extern crate foo2; | @@ -49,7 +49,7 @@ error[E0432]: unresolved import `baz2` LL | use baz2::*; | ^^^^ use of unresolved module or unlinked crate `baz2` | -help: consider importing the `baz2` crate +help: if you wanted to use a crate named `baz2`, use `cargo add baz2` to add it to your `Cargo.toml` and import it in your code | LL + extern crate baz2; | diff --git a/tests/ui/issues/issue-33293.stderr b/tests/ui/issues/issue-33293.stderr index e5dfb95c8d0e..509d575fc258 100644 --- a/tests/ui/issues/issue-33293.stderr +++ b/tests/ui/issues/issue-33293.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `aaa | LL | aaa::bbb(_) => () | ^^^ use of unresolved module or unlinked crate `aaa` + | + = help: if you wanted to use a crate named `aaa`, use `cargo add aaa` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/keyword/extern/keyword-extern-as-identifier-use.stderr b/tests/ui/keyword/extern/keyword-extern-as-identifier-use.stderr index 3b11e9684d90..f6da7a8fd871 100644 --- a/tests/ui/keyword/extern/keyword-extern-as-identifier-use.stderr +++ b/tests/ui/keyword/extern/keyword-extern-as-identifier-use.stderr @@ -15,7 +15,7 @@ error[E0432]: unresolved import `r#extern` LL | use extern::foo; | ^^^^^^ use of unresolved module or unlinked crate `r#extern` | -help: consider importing the `r#extern` crate +help: if you wanted to use a crate named `r#extern`, use `cargo add r#extern` to add it to your `Cargo.toml` and import it in your code | LL + extern crate r#extern; | diff --git a/tests/ui/macros/builtin-prelude-no-accidents.stderr b/tests/ui/macros/builtin-prelude-no-accidents.stderr index 6908b38acc1d..46690544395d 100644 --- a/tests/ui/macros/builtin-prelude-no-accidents.stderr +++ b/tests/ui/macros/builtin-prelude-no-accidents.stderr @@ -4,6 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `env LL | env::current_dir; | ^^^ use of unresolved module or unlinked crate `env` | + = help: if you wanted to use a crate named `env`, use `cargo add env` to add it to your `Cargo.toml` help: consider importing this module | LL + use std::env; @@ -15,6 +16,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `pan LL | type A = panic::PanicInfo; | ^^^^^ use of unresolved module or unlinked crate `panic` | + = help: if you wanted to use a crate named `panic`, use `cargo add panic` to add it to your `Cargo.toml` help: consider importing this module | LL + use std::panic; @@ -26,6 +28,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `vec LL | type B = vec::Vec; | ^^^ use of unresolved module or unlinked crate `vec` | + = help: if you wanted to use a crate named `vec`, use `cargo add vec` to add it to your `Cargo.toml` help: consider importing this module | LL + use std::vec; diff --git a/tests/ui/macros/macro_path_as_generic_bound.stderr b/tests/ui/macros/macro_path_as_generic_bound.stderr index 306f887a1f07..07a0bd883497 100644 --- a/tests/ui/macros/macro_path_as_generic_bound.stderr +++ b/tests/ui/macros/macro_path_as_generic_bound.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `m` | LL | foo!(m::m2::A); | ^ use of unresolved module or unlinked crate `m` + | + = help: if you wanted to use a crate named `m`, use `cargo add m` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/mir/issue-121103.stderr b/tests/ui/mir/issue-121103.stderr index fc7e31ad26de..b1b5b43300b9 100644 --- a/tests/ui/mir/issue-121103.stderr +++ b/tests/ui/mir/issue-121103.stderr @@ -3,12 +3,16 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `lib | LL | fn main(_: as lib2::TypeFn>::Output) {} | ^^^^ use of unresolved module or unlinked crate `lib2` + | + = help: if you wanted to use a crate named `lib2`, use `cargo add lib2` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `lib2` --> $DIR/issue-121103.rs:1:13 | LL | fn main(_: as lib2::TypeFn>::Output) {} | ^^^^ use of unresolved module or unlinked crate `lib2` + | + = help: if you wanted to use a crate named `lib2`, use `cargo add lib2` to add it to your `Cargo.toml` error: aborting due to 2 previous errors diff --git a/tests/ui/modules_and_files_visibility/mod_file_disambig.stderr b/tests/ui/modules_and_files_visibility/mod_file_disambig.stderr index 70264debc6d4..7d76df83dff3 100644 --- a/tests/ui/modules_and_files_visibility/mod_file_disambig.stderr +++ b/tests/ui/modules_and_files_visibility/mod_file_disambig.stderr @@ -11,6 +11,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `mod | LL | assert_eq!(mod_file_aux::bar(), 10); | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `mod_file_aux` + | + = help: if you wanted to use a crate named `mod_file_aux`, use `cargo add mod_file_aux` to add it to your `Cargo.toml` error: aborting due to 2 previous errors diff --git a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr index 994dbd96695d..03e05ef43461 100644 --- a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr +++ b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr @@ -26,6 +26,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `pat | LL | path::path::Struct::() | ^^^^ use of unresolved module or unlinked crate `path` + | + = help: if you wanted to use a crate named `path`, use `cargo add path` to add it to your `Cargo.toml` error[E0412]: cannot find type `T` in this scope --> $DIR/const-param-decl-on-type-instead-of-impl.rs:8:15 diff --git a/tests/ui/parser/dyn-trait-compatibility.stderr b/tests/ui/parser/dyn-trait-compatibility.stderr index 61ff6cc90ec1..ffdd8b74c029 100644 --- a/tests/ui/parser/dyn-trait-compatibility.stderr +++ b/tests/ui/parser/dyn-trait-compatibility.stderr @@ -45,6 +45,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `dyn | LL | type A1 = dyn::dyn; | ^^^ use of unresolved module or unlinked crate `dyn` + | + = help: if you wanted to use a crate named `dyn`, use `cargo add dyn` to add it to your `Cargo.toml` error: aborting due to 8 previous errors diff --git a/tests/ui/parser/mod_file_not_exist.rs b/tests/ui/parser/mod_file_not_exist.rs index 8aa3b63878ce..979963c76e27 100644 --- a/tests/ui/parser/mod_file_not_exist.rs +++ b/tests/ui/parser/mod_file_not_exist.rs @@ -6,4 +6,5 @@ mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` fn main() { assert_eq!(mod_file_aux::bar(), 10); //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `mod_file_aux` + //~| HELP if you wanted to use a crate named `mod_file_aux`, use `cargo add mod_file_aux` to add it to your `Cargo.toml` } diff --git a/tests/ui/parser/mod_file_not_exist.stderr b/tests/ui/parser/mod_file_not_exist.stderr index 8fc5aa932b48..3990186b7df4 100644 --- a/tests/ui/parser/mod_file_not_exist.stderr +++ b/tests/ui/parser/mod_file_not_exist.stderr @@ -12,6 +12,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `mod | LL | assert_eq!(mod_file_aux::bar(), 10); | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `mod_file_aux` + | + = help: if you wanted to use a crate named `mod_file_aux`, use `cargo add mod_file_aux` to add it to your `Cargo.toml` error: aborting due to 2 previous errors diff --git a/tests/ui/privacy/restricted/test.stderr b/tests/ui/privacy/restricted/test.stderr index 63db722756f1..a4a55ce65996 100644 --- a/tests/ui/privacy/restricted/test.stderr +++ b/tests/ui/privacy/restricted/test.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `bad LL | pub(in bad::path) mod m1 {} | ^^^ use of unresolved module or unlinked crate `bad` | -help: consider importing the `bad` crate +help: if you wanted to use a crate named `bad`, use `cargo add bad` to add it to your `Cargo.toml` and import it in your code | LL + extern crate bad; | diff --git a/tests/ui/resolve/112590-2.stderr b/tests/ui/resolve/112590-2.stderr index 0b901fb6d13f..57ffd85d25cf 100644 --- a/tests/ui/resolve/112590-2.stderr +++ b/tests/ui/resolve/112590-2.stderr @@ -20,6 +20,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `fox LL | let _: Vec = fox::bar::baz::MyVec::new(); | ^^^ use of unresolved module or unlinked crate `fox` | + = help: if you wanted to use a crate named `fox`, use `cargo add fox` to add it to your `Cargo.toml` help: consider importing this struct through its public re-export | LL + use foo::bar::baz::MyVec; @@ -36,6 +37,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `vec LL | type _B = vec::Vec::; | ^^^ use of unresolved module or unlinked crate `vec` | + = help: if you wanted to use a crate named `vec`, use `cargo add vec` to add it to your `Cargo.toml` help: consider importing this module | LL + use std::vec; @@ -65,6 +67,8 @@ LL | let _t: Vec = vec::new(); | | | use of unresolved module or unlinked crate `vec` | help: a struct with a similar name exists (notice the capitalization): `Vec` + | + = help: if you wanted to use a crate named `vec`, use `cargo add vec` to add it to your `Cargo.toml` error: aborting due to 5 previous errors diff --git a/tests/ui/resolve/bad-module.stderr b/tests/ui/resolve/bad-module.stderr index 13b024a0cb69..9da0207534e5 100644 --- a/tests/ui/resolve/bad-module.stderr +++ b/tests/ui/resolve/bad-module.stderr @@ -3,12 +3,16 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo | LL | let foo = foo::bar::baz(); | ^^^ use of unresolved module or unlinked crate `foo` + | + = help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `thing` --> $DIR/bad-module.rs:2:15 | LL | let foo = thing::len(Vec::new()); | ^^^^^ use of unresolved module or unlinked crate `thing` + | + = help: if you wanted to use a crate named `thing`, use `cargo add thing` to add it to your `Cargo.toml` error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/editions-crate-root-2015.stderr b/tests/ui/resolve/editions-crate-root-2015.stderr index 19aebbe82d86..117da7b9bd25 100644 --- a/tests/ui/resolve/editions-crate-root-2015.stderr +++ b/tests/ui/resolve/editions-crate-root-2015.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `non LL | fn global_inner(_: ::nonexistant::Foo) { | ^^^^^^^^^^^ use of unresolved module or unlinked crate `nonexistant` | -help: consider importing the `nonexistant` crate +help: if you wanted to use a crate named `nonexistant`, use `cargo add nonexistant` to add it to your `Cargo.toml` and import it in your code | LL + extern crate nonexistant; | @@ -15,7 +15,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `non LL | fn crate_inner(_: crate::nonexistant::Foo) { | ^^^^^^^^^^^ use of unresolved module or unlinked crate `nonexistant` | -help: consider importing the `nonexistant` crate +help: if you wanted to use a crate named `nonexistant`, use `cargo add nonexistant` to add it to your `Cargo.toml` and import it in your code | LL + extern crate nonexistant; | diff --git a/tests/ui/resolve/export-fully-qualified-2018.stderr b/tests/ui/resolve/export-fully-qualified-2018.stderr index b2517c150222..bdd3292db557 100644 --- a/tests/ui/resolve/export-fully-qualified-2018.stderr +++ b/tests/ui/resolve/export-fully-qualified-2018.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo | LL | pub fn bar() { foo::baz(); } | ^^^ use of unresolved module or unlinked crate `foo` + | + = help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/resolve/export-fully-qualified.stderr b/tests/ui/resolve/export-fully-qualified.stderr index 332641b1704a..740435933d0f 100644 --- a/tests/ui/resolve/export-fully-qualified.stderr +++ b/tests/ui/resolve/export-fully-qualified.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `foo | LL | pub fn bar() { foo::baz(); } | ^^^ use of unresolved module or unlinked crate `foo` + | + = help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/resolve/extern-prelude-fail.stderr b/tests/ui/resolve/extern-prelude-fail.stderr index 25677aed59bd..9f3f368a57a4 100644 --- a/tests/ui/resolve/extern-prelude-fail.stderr +++ b/tests/ui/resolve/extern-prelude-fail.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `extern_prelude` LL | use extern_prelude::S; | ^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `extern_prelude` | -help: consider importing the `extern_prelude` crate +help: if you wanted to use a crate named `extern_prelude`, use `cargo add extern_prelude` to add it to your `Cargo.toml` and import it in your code | LL + extern crate extern_prelude; | @@ -15,7 +15,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `ext LL | let s = ::extern_prelude::S; | ^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `extern_prelude` | -help: consider importing the `extern_prelude` crate +help: if you wanted to use a crate named `extern_prelude`, use `cargo add extern_prelude` to add it to your `Cargo.toml` and import it in your code | LL + extern crate extern_prelude; | diff --git a/tests/ui/resolve/issue-101749-2.stderr b/tests/ui/resolve/issue-101749-2.stderr index da12986e38ec..b21f9b5182bc 100644 --- a/tests/ui/resolve/issue-101749-2.stderr +++ b/tests/ui/resolve/issue-101749-2.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `rec | LL | let _ = rect::area(); | ^^^^ use of unresolved module or unlinked crate `rect` + | + = help: if you wanted to use a crate named `rect`, use `cargo add rect` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/resolve/issue-101749.stderr b/tests/ui/resolve/issue-101749.stderr index a010e53b9e7a..35961893d7cf 100644 --- a/tests/ui/resolve/issue-101749.stderr +++ b/tests/ui/resolve/issue-101749.stderr @@ -4,6 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `rec LL | let _ = rect::area(); | ^^^^ use of unresolved module or unlinked crate `rect` | + = help: if you wanted to use a crate named `rect`, use `cargo add rect` to add it to your `Cargo.toml` help: you may have meant to call an instance method | LL | let _ = rect.area(); diff --git a/tests/ui/resolve/issue-82865.stderr b/tests/ui/resolve/issue-82865.stderr index ee57235074d5..6680121f26e8 100644 --- a/tests/ui/resolve/issue-82865.stderr +++ b/tests/ui/resolve/issue-82865.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `x` LL | use x::y::z; | ^ use of unresolved module or unlinked crate `x` | -help: consider importing the `x` crate +help: if you wanted to use a crate named `x`, use `cargo add x` to add it to your `Cargo.toml` and import it in your code | LL + extern crate x; | diff --git a/tests/ui/resolve/resolve-bad-visibility.stderr b/tests/ui/resolve/resolve-bad-visibility.stderr index 98d2753cf502..dc62d747a656 100644 --- a/tests/ui/resolve/resolve-bad-visibility.stderr +++ b/tests/ui/resolve/resolve-bad-visibility.stderr @@ -22,7 +22,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `non LL | pub(in nonexistent) struct G; | ^^^^^^^^^^^ use of unresolved module or unlinked crate `nonexistent` | -help: consider importing the `nonexistent` crate +help: if you wanted to use a crate named `nonexistent`, use `cargo add nonexistent` to add it to your `Cargo.toml` and import it in your code | LL + extern crate nonexistent; | @@ -33,7 +33,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `too LL | pub(in too_soon) struct H; | ^^^^^^^^ use of unresolved module or unlinked crate `too_soon` | -help: consider importing the `too_soon` crate +help: if you wanted to use a crate named `too_soon`, use `cargo add too_soon` to add it to your `Cargo.toml` and import it in your code | LL + extern crate too_soon; | diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr index 761e5f2e1ed7..c74053209dd6 100644 --- a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr @@ -3,6 +3,8 @@ error[E0432]: unresolved import `xcrate` | LL | use xcrate::S; | ^^^^^^ use of unresolved module or unlinked crate `xcrate` + | + = help: if you wanted to use a crate named `xcrate`, use `cargo add xcrate` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/rust-2018/unresolved-asterisk-imports.stderr b/tests/ui/rust-2018/unresolved-asterisk-imports.stderr index 351dbbf5ed86..b5dd1c249f45 100644 --- a/tests/ui/rust-2018/unresolved-asterisk-imports.stderr +++ b/tests/ui/rust-2018/unresolved-asterisk-imports.stderr @@ -3,6 +3,8 @@ error[E0432]: unresolved import `not_existing_crate` | LL | use not_existing_crate::*; | ^^^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `not_existing_crate` + | + = help: if you wanted to use a crate named `not_existing_crate`, use `cargo add not_existing_crate` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-112590-suggest-import.stderr b/tests/ui/suggestions/issue-112590-suggest-import.stderr index 34b5efda3a46..6c3c333f01e7 100644 --- a/tests/ui/suggestions/issue-112590-suggest-import.stderr +++ b/tests/ui/suggestions/issue-112590-suggest-import.stderr @@ -4,6 +4,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `fmt LL | impl fmt::Debug for S { | ^^^ use of unresolved module or unlinked crate `fmt` | + = help: if you wanted to use a crate named `fmt`, use `cargo add fmt` to add it to your `Cargo.toml` help: consider importing this module | LL + use std::fmt; @@ -15,6 +16,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `fmt LL | fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { | ^^^ use of unresolved module or unlinked crate `fmt` | + = help: if you wanted to use a crate named `fmt`, use `cargo add fmt` to add it to your `Cargo.toml` help: consider importing this module | LL + use std::fmt; @@ -26,6 +28,7 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `fmt LL | fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { | ^^^ use of unresolved module or unlinked crate `fmt` | + = help: if you wanted to use a crate named `fmt`, use `cargo add fmt` to add it to your `Cargo.toml` help: consider importing this module | LL + use std::fmt; diff --git a/tests/ui/typeck/issue-120856.stderr b/tests/ui/typeck/issue-120856.stderr index 77792fd8b5b1..33c2934c8c3b 100644 --- a/tests/ui/typeck/issue-120856.stderr +++ b/tests/ui/typeck/issue-120856.stderr @@ -6,6 +6,8 @@ LL | pub type Archived = ::Archived; | | | use of unresolved module or unlinked crate `n` | help: a trait with a similar name exists: `Fn` + | + = help: if you wanted to use a crate named `n`, use `cargo add n` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `m` --> $DIR/issue-120856.rs:1:25 @@ -15,6 +17,8 @@ LL | pub type Archived = ::Archived; | | | use of unresolved module or unlinked crate `m` | help: a type parameter with a similar name exists: `T` + | + = help: if you wanted to use a crate named `m`, use `cargo add m` to add it to your `Cargo.toml` error: aborting due to 2 previous errors diff --git a/tests/ui/typeck/path-to-method-sugg-unresolved-expr.stderr b/tests/ui/typeck/path-to-method-sugg-unresolved-expr.stderr index 608ff4baf214..9e53c148f3ef 100644 --- a/tests/ui/typeck/path-to-method-sugg-unresolved-expr.stderr +++ b/tests/ui/typeck/path-to-method-sugg-unresolved-expr.stderr @@ -3,6 +3,8 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `pag | LL | let page_size = page_size::get(); | ^^^^^^^^^ use of unresolved module or unlinked crate `page_size` + | + = help: if you wanted to use a crate named `page_size`, use `cargo add page_size` to add it to your `Cargo.toml` error: aborting due to 1 previous error diff --git a/tests/ui/unresolved/unresolved-asterisk-imports.stderr b/tests/ui/unresolved/unresolved-asterisk-imports.stderr index 4e258e08e094..761ceaca4f67 100644 --- a/tests/ui/unresolved/unresolved-asterisk-imports.stderr +++ b/tests/ui/unresolved/unresolved-asterisk-imports.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `not_existing_crate` LL | use not_existing_crate::*; | ^^^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `not_existing_crate` | -help: consider importing the `not_existing_crate` crate +help: if you wanted to use a crate named `not_existing_crate`, use `cargo add not_existing_crate` to add it to your `Cargo.toml` and import it in your code | LL + extern crate not_existing_crate; | diff --git a/tests/ui/unresolved/unresolved-import.rs b/tests/ui/unresolved/unresolved-import.rs index cca000d672d1..ee79ad0acc82 100644 --- a/tests/ui/unresolved/unresolved-import.rs +++ b/tests/ui/unresolved/unresolved-import.rs @@ -1,7 +1,7 @@ use foo::bar; //~^ ERROR unresolved import `foo` [E0432] //~| NOTE use of unresolved module or unlinked crate `foo` -//~| HELP consider importing the `foo` crate +//~| HELP if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml` and import it in your code //~| SUGGESTION extern crate foo; use bar::Baz as x; diff --git a/tests/ui/unresolved/unresolved-import.stderr b/tests/ui/unresolved/unresolved-import.stderr index f7a83bcd9e21..87f01af85685 100644 --- a/tests/ui/unresolved/unresolved-import.stderr +++ b/tests/ui/unresolved/unresolved-import.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `foo` LL | use foo::bar; | ^^^ use of unresolved module or unlinked crate `foo` | -help: consider importing the `foo` crate +help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml` and import it in your code | LL + extern crate foo; |