diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 539b4a1d5e714..2e9c5acf33f7d 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2558,7 +2558,7 @@ fn show_candidates( for candidate in accessible_path_strings { msg.push('\n'); - msg.push_str(&candidate.0); + msg.push_str(&format!("use {};", &candidate.0)); } err.help(msg); diff --git a/tests/ui/empty/empty-macro-use.stderr b/tests/ui/empty/empty-macro-use.stderr index 5d552e4c40846..1ccdf857ae8a5 100644 --- a/tests/ui/empty/empty-macro-use.stderr +++ b/tests/ui/empty/empty-macro-use.stderr @@ -4,7 +4,8 @@ error: cannot find macro `macro_two` in this scope LL | macro_two!(); | ^^^^^^^^^ | -help: consider importing this macro + = help: consider importing this macro: + use two_macros::macro_two; | LL + use two_macros::macro_two; | diff --git a/tests/ui/hygiene/globs.stderr b/tests/ui/hygiene/globs.stderr index 180172644402b..52468ce1a9b2e 100644 --- a/tests/ui/hygiene/globs.stderr +++ b/tests/ui/hygiene/globs.stderr @@ -52,7 +52,7 @@ LL | n!(f); | ^ not found in this scope | = help: consider importing this function: - foo::f + use foo::f; = note: this error originates in the macro `n` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find function `f` in this scope @@ -65,7 +65,7 @@ LL | f | ^ not found in this scope | = help: consider importing this function: - foo::f + use foo::f; = note: this error originates in the macro `n` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/tests/ui/hygiene/no_implicit_prelude-2018.stderr b/tests/ui/hygiene/no_implicit_prelude-2018.stderr index b22f3e75b6f4f..a0ad0530276c2 100644 --- a/tests/ui/hygiene/no_implicit_prelude-2018.stderr +++ b/tests/ui/hygiene/no_implicit_prelude-2018.stderr @@ -4,7 +4,8 @@ error: cannot find macro `print` in this scope LL | print!(); | ^^^^^ | -help: consider importing this macro + = help: consider importing this macro: + use std::print; | LL + use std::print; | diff --git a/tests/ui/imports/bad-import-in-nested.stderr b/tests/ui/imports/bad-import-in-nested.stderr index b6b1bc5fccf02..019abf6144218 100644 --- a/tests/ui/imports/bad-import-in-nested.stderr +++ b/tests/ui/imports/bad-import-in-nested.stderr @@ -5,7 +5,7 @@ LL | use super::{super::C::D::AA, AA as _}; | ^^^^^^^^^^^^^^^ no `AA` in `C::D` | = help: consider importing this type alias instead: - crate::A::AA + use crate::A::AA; error[E0432]: unresolved import `crate::C::AA` --> $DIR/bad-import-in-nested.rs:20:26 @@ -14,7 +14,7 @@ LL | use crate::C::{self, AA}; | ^^ no `AA` in `C` | = help: consider importing this type alias instead: - crate::A::AA + use crate::A::AA; error[E0432]: unresolved import `crate::C::BB` --> $DIR/bad-import-in-nested.rs:23:20 @@ -23,7 +23,7 @@ LL | use crate::{A, C::BB}; | ^^^^^ no `BB` in `C` | = help: consider importing this type alias instead: - crate::A::BB + use crate::A::BB; error: aborting due to 3 previous errors diff --git a/tests/ui/macros/issue-88228.stderr b/tests/ui/macros/issue-88228.stderr index 1dbe2b77be2d9..b40ae5643dbe4 100644 --- a/tests/ui/macros/issue-88228.stderr +++ b/tests/ui/macros/issue-88228.stderr @@ -4,7 +4,8 @@ error: cannot find macro `bla` in this scope LL | bla!(); | ^^^ | -help: consider importing this macro + = help: consider importing this macro: + use crate::hey::bla; | LL + use crate::hey::bla; | @@ -23,7 +24,8 @@ error: cannot find derive macro `Bla` in this scope LL | #[derive(Bla)] | ^^^ | -help: consider importing this derive macro + = help: consider importing this derive macro: + use crate::hey::Bla; | LL + use crate::hey::Bla; | diff --git a/tests/ui/macros/macro-use-wrong-name.stderr b/tests/ui/macros/macro-use-wrong-name.stderr index 36339542ac61f..c77cafa4c38c0 100644 --- a/tests/ui/macros/macro-use-wrong-name.stderr +++ b/tests/ui/macros/macro-use-wrong-name.stderr @@ -9,7 +9,8 @@ LL | macro_two!(); LL | macro_rules! macro_one { () => ("one") } | ---------------------- similarly named macro `macro_one` defined here | -help: a macro with a similar name exists + = help: consider importing this macro: + use two_macros::macro_two; | LL | macro_one!(); | ~~~~~~~~~ diff --git a/tests/ui/missing/missing-macro-use.stderr b/tests/ui/missing/missing-macro-use.stderr index e1d80f52daddc..9acda61bf05f3 100644 --- a/tests/ui/missing/missing-macro-use.stderr +++ b/tests/ui/missing/missing-macro-use.stderr @@ -4,7 +4,8 @@ error: cannot find macro `macro_two` in this scope LL | macro_two!(); | ^^^^^^^^^ | -help: consider importing this macro + = help: consider importing this macro: + use two_macros::macro_two; | LL + use two_macros::macro_two; | diff --git a/tests/ui/proc-macro/derive-helper-shadowing.stderr b/tests/ui/proc-macro/derive-helper-shadowing.stderr index 7e7870b295127..58caf3426badf 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.stderr +++ b/tests/ui/proc-macro/derive-helper-shadowing.stderr @@ -16,8 +16,9 @@ error: cannot find attribute `empty_helper` in this scope LL | #[derive(GenHelperUse)] | ^^^^^^^^^^^^ | + = help: consider importing this attribute macro: + use empty_helper; = note: this error originates in the derive macro `GenHelperUse` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing this attribute macro | LL + use empty_helper; | @@ -31,8 +32,9 @@ LL | #[empty_helper] LL | gen_helper_use!(); | ----------------- in this macro invocation | + = help: consider importing this attribute macro: + use crate::empty_helper; = note: this error originates in the macro `gen_helper_use` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing this attribute macro | LL + use crate::empty_helper; | diff --git a/tests/ui/proc-macro/generate-mod.stderr b/tests/ui/proc-macro/generate-mod.stderr index db629b5b5e239..912c3755e3abb 100644 --- a/tests/ui/proc-macro/generate-mod.stderr +++ b/tests/ui/proc-macro/generate-mod.stderr @@ -5,7 +5,7 @@ LL | generate_mod::check!(); | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | = help: consider importing this struct: - FromOutside + use FromOutside; = note: this error originates in the macro `generate_mod::check` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `Outer` in this scope @@ -15,7 +15,7 @@ LL | generate_mod::check!(); | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | = help: consider importing this struct: - Outer + use Outer; = note: this error originates in the macro `generate_mod::check` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `FromOutside` in this scope @@ -25,7 +25,7 @@ LL | #[generate_mod::check_attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | = help: consider importing this struct: - FromOutside + use FromOutside; = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `OuterAttr` in this scope @@ -35,7 +35,7 @@ LL | #[generate_mod::check_attr] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope | = help: consider importing this struct: - OuterAttr + use OuterAttr; = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find type `FromOutside` in this scope