Rollup merge of #75209 - Hirrolot:suggest-macro-imports, r=estebank
Suggest imports of unresolved macros Closes https://github.com/rust-lang/rust/issues/75191.
This commit is contained in:
commit
7581bb7c02
6 changed files with 26 additions and 0 deletions
|
@ -922,6 +922,17 @@ impl<'a> Resolver<'a> {
|
||||||
);
|
);
|
||||||
self.add_typo_suggestion(err, suggestion, ident.span);
|
self.add_typo_suggestion(err, suggestion, ident.span);
|
||||||
|
|
||||||
|
let import_suggestions = self.lookup_import_candidates(
|
||||||
|
ident,
|
||||||
|
Namespace::MacroNS,
|
||||||
|
parent_scope,
|
||||||
|
|res| match res {
|
||||||
|
Res::Def(DefKind::Macro(MacroKind::Bang), _) => true,
|
||||||
|
_ => false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
show_candidates(err, None, &import_suggestions, false, true);
|
||||||
|
|
||||||
if macro_kind == MacroKind::Derive && (ident.name == sym::Send || ident.name == sym::Sync) {
|
if macro_kind == MacroKind::Derive && (ident.name == sym::Send || ident.name == sym::Sync) {
|
||||||
let msg = format!("unsafe traits like `{}` should be implemented explicitly", ident);
|
let msg = format!("unsafe traits like `{}` should be implemented explicitly", ident);
|
||||||
err.span_note(ident.span, &msg);
|
err.span_note(ident.span, &msg);
|
||||||
|
|
|
@ -3,6 +3,9 @@ error: cannot find macro `macro_two` in this scope
|
||||||
|
|
|
|
||||||
LL | macro_two!();
|
LL | macro_two!();
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: consider importing this macro:
|
||||||
|
two_macros::macro_two
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ error: cannot find macro `print` in this scope
|
||||||
|
|
|
|
||||||
LL | print!();
|
LL | print!();
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: consider importing this macro:
|
||||||
|
std::print
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@ error: cannot find macro `panic` in this scope
|
||||||
LL | assert_eq!(0, 0);
|
LL | assert_eq!(0, 0);
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
|
= note: consider importing one of these items:
|
||||||
|
core::panic
|
||||||
|
std::panic
|
||||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0433]: failed to resolve: use of undeclared type `Vec`
|
error[E0433]: failed to resolve: use of undeclared type `Vec`
|
||||||
|
|
|
@ -8,6 +8,9 @@ LL | macro_two!();
|
||||||
|
|
|
|
||||||
LL | macro_rules! macro_one { () => ("one") }
|
LL | macro_rules! macro_one { () => ("one") }
|
||||||
| ---------------------- similarly named macro `macro_one` defined here
|
| ---------------------- similarly named macro `macro_one` defined here
|
||||||
|
|
|
||||||
|
= note: consider importing this macro:
|
||||||
|
two_macros::macro_two
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ error: cannot find macro `macro_two` in this scope
|
||||||
|
|
|
|
||||||
LL | macro_two!();
|
LL | macro_two!();
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: consider importing this macro:
|
||||||
|
two_macros::macro_two
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue