mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Drop vis in Item.
This commit is contained in:
parent
6ec33dfe49
commit
04024bacba
4 changed files with 13 additions and 13 deletions
|
@ -260,7 +260,7 @@ impl LateLintPass<'_> for EnumVariantNames {
|
|||
}
|
||||
// The `module_name_repetitions` lint should only trigger if the item has the module in its
|
||||
// name. Having the same name is accepted.
|
||||
if item.vis.node.is_pub() && item_camel.len() > mod_camel.len() {
|
||||
if cx.tcx.visibility(item.def_id).is_public() && item_camel.len() > mod_camel.len() {
|
||||
let matching = count_match_start(mod_camel, &item_camel);
|
||||
let rmatching = count_match_end(mod_camel, &item_camel);
|
||||
let nchars = mod_camel.chars().count();
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Item, ItemKind, VisibilityKind};
|
||||
use rustc_hir::{Item, ItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::def_id::CRATE_DEF_ID;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
|
@ -41,7 +43,7 @@ impl_lint_pass!(RedundantPubCrate => [REDUNDANT_PUB_CRATE]);
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
if let VisibilityKind::Crate { .. } = item.vis.node {
|
||||
if cx.tcx.visibility(item.def_id) == ty::Visibility::Restricted(CRATE_DEF_ID.to_def_id()) {
|
||||
if !cx.access_levels.is_exported(item.def_id) && self.is_exported.last() == Some(&false) {
|
||||
let span = item.span.with_hi(item.ident.span.hi());
|
||||
let descr = cx.tcx.def_kind(item.def_id).descr(item.def_id.to_def_id());
|
||||
|
@ -52,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
|
|||
&format!("pub(crate) {} inside private module", descr),
|
||||
|diag| {
|
||||
diag.span_suggestion(
|
||||
item.vis.span,
|
||||
item.vis_span,
|
||||
"consider using",
|
||||
"pub".to_string(),
|
||||
Applicability::MachineApplicable,
|
||||
|
|
|
@ -357,14 +357,10 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
|
|||
fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
let did = item.def_id;
|
||||
println!("item `{}`", item.ident.name);
|
||||
match item.vis.node {
|
||||
hir::VisibilityKind::Public => println!("public"),
|
||||
hir::VisibilityKind::Crate(_) => println!("visible crate wide"),
|
||||
hir::VisibilityKind::Restricted { path, .. } => println!(
|
||||
"visible in module `{}`",
|
||||
rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_path(path, false))
|
||||
),
|
||||
hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"),
|
||||
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::Invisible => println!("invisible"),
|
||||
}
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(ref _renamed_from) => {
|
||||
|
|
|
@ -8,6 +8,7 @@ use rustc_hir::{
|
|||
Item, ItemKind, PathSegment, UseKind,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::{sym, BytePos};
|
||||
|
@ -115,7 +116,8 @@ impl LateLintPass<'_> for WildcardImports {
|
|||
if is_test_module_or_function(cx.tcx, item) {
|
||||
self.test_modules_deep = self.test_modules_deep.saturating_add(1);
|
||||
}
|
||||
if item.vis.node.is_pub() || item.vis.node.is_pub_restricted() {
|
||||
let module = cx.tcx.parent_module_from_def_id(item.def_id);
|
||||
if cx.tcx.visibility(item.def_id) != ty::Visibility::Restricted(module.to_def_id()) {
|
||||
return;
|
||||
}
|
||||
if_chain! {
|
||||
|
|
Loading…
Reference in a new issue