diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-02-14 13:20:47 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-04-23 23:03:18 +0200 |
| commit | ec3afba5d48427801a490ba91e6ce6d0bd3bfae9 (patch) | |
| tree | c5d1f4ddf042a7028255cfe731124b4bb5849786 | |
| parent | 04024bacba1f74f5d8cdb7fb91798ba77bc2b8f5 (diff) | |
| download | rust-ec3afba5d48427801a490ba91e6ce6d0bd3bfae9.tar.gz rust-ec3afba5d48427801a490ba91e6ce6d0bd3bfae9.zip | |
Make clippy inspector more precise.
| -rw-r--r-- | clippy_lints/src/utils/inspector.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index e4abfd07866..37b114a0cfb 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -48,7 +48,13 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector { println!("impl item `{}`", item.ident.name); match cx.tcx.visibility(item.def_id) { ty::Visibility::Public => println!("public"), - ty::Visibility::Restricted(def_id) => println!("visible in module `{}`", cx.tcx.def_path_str(def_id)), + ty::Visibility::Restricted(def_id) => { + if def_id.is_top_level_module() { + println!("visible crate wide") + } else { + println!("visible in module `{}`", cx.tcx.def_path_str(def_id)) + } + }, ty::Visibility::Invisible => println!("invisible"), } match item.kind { @@ -359,7 +365,13 @@ fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) { println!("item `{}`", item.ident.name); match cx.tcx.visibility(item.def_id) { ty::Visibility::Public => println!("public"), - ty::Visibility::Restricted(def_id) => println!("visible in module `{}`", cx.tcx.def_path_str(def_id)), + ty::Visibility::Restricted(def_id) => { + if def_id.is_top_level_module() { + println!("visible crate wide") + } else { + println!("visible in module `{}`", cx.tcx.def_path_str(def_id)) + } + }, ty::Visibility::Invisible => println!("invisible"), } match item.kind { |
