Skip to content

Commit 5c8e3c0

Browse files
committed
make a help text for 'cannot find macro' actionable
1 parent 7f42e58 commit 5c8e3c0

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2441,10 +2441,9 @@ fn show_candidates(
24412441

24422442
for candidate in accessible_path_strings {
24432443
msg.push('\n');
2444-
msg.push_str(&candidate.0);
2444+
msg.push_str(&format!("use {};", &candidate.0));
24452445
}
2446-
2447-
err.note(&msg);
2446+
err.help(&msg);
24482447
}
24492448
} else if !matches!(mode, DiagnosticMode::Import) {
24502449
assert!(!inaccessible_path_strings.is_empty());

src/test/ui/macros/issue-102601.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
mod hey {
2+
pub use std::println as bitflags;
3+
}
4+
5+
fn main() {
6+
bitflags! { //~ ERROR cannot find macro `bitflags` in this scope
7+
struct Flags: u32 {
8+
const A = 0b00000001;
9+
}
10+
}
11+
}
12+
//~ HELP consider importing this macro:
13+
// use hey::bitflags;
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: cannot find macro `bitflags` in this scope
2+
--> $DIR/issue-102601.rs:6:5
3+
|
4+
LL | bitflags! {
5+
| ^^^^^^^^
6+
|
7+
= help: consider importing this macro:
8+
use hey::bitflags;
9+
10+
error: aborting due to previous error
11+

0 commit comments

Comments
 (0)