Skip to content

Commit 56fa7b3

Browse files
committed
find imported macros for sugg
1 parent 461a9b1 commit 56fa7b3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

clippy_lints/src/macro_use.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ impl EarlyLintPass for MacroUseImport {
3636
.iter()
3737
.find(|attr| attr.ident().map(|s| s.to_string()) == Some("macro_use".to_string()));
3838
then {
39+
let import_path = snippet(ecx, use_tree.span, "_");
40+
let mac_names = find_used_macros(ecx, &import_path);
3941
let msg = "`macro_use` attributes are no longer needed in the Rust 2018 edition";
40-
let help = format!("use {}::<macro name>", snippet(ecx, use_tree.span, "_"));
42+
let help = format!("use {}::<macro name>", import_path);
4143
span_lint_and_sugg(
4244
ecx,
4345
MACRO_USE_IMPORT,
@@ -51,3 +53,9 @@ impl EarlyLintPass for MacroUseImport {
5153
}
5254
}
5355
}
56+
57+
fn find_used_macros(ecx: &EarlyContext<'_>, path: &str) {
58+
for it in ecx.krate.module.items.iter() {
59+
println!("{:#?}", it);
60+
}
61+
}

0 commit comments

Comments
 (0)