]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/redundant_pub_crate.rs
ast/hir: Rename field-related structures
[rust.git] / clippy_lints / src / redundant_pub_crate.rs
index af4ab367f5fae06a077c3ed77a79a7e4ec9c8ad3..c876bae2303ad29f0252d0ec425d1b9ca17374c7 100644 (file)
@@ -28,7 +28,7 @@
     /// }
     /// ```
     pub REDUNDANT_PUB_CRATE,
-    style,
+    nursery,
     "Using `pub(crate)` visibility on items that are not crate visible due to the visibility of the module that contains them."
 }
 
@@ -39,19 +39,20 @@ pub struct RedundantPubCrate {
 
 impl_lint_pass!(RedundantPubCrate => [REDUNDANT_PUB_CRATE]);
 
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantPubCrate {
-    fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'tcx>) {
+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.access_levels.is_exported(item.hir_id) {
+            if !cx.access_levels.is_exported(item.hir_id()) {
                 if let Some(false) = self.is_exported.last() {
                     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());
                     span_lint_and_then(
                         cx,
                         REDUNDANT_PUB_CRATE,
                         span,
-                        &format!("pub(crate) {} inside private module", item.kind.descr()),
-                        |db| {
-                            db.span_suggestion(
+                        &format!("pub(crate) {} inside private module", descr),
+                        |diag| {
+                            diag.span_suggestion(
                                 item.vis.span,
                                 "consider using",
                                 "pub".to_string(),
@@ -64,11 +65,11 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'tcx>) {
         }
 
         if let ItemKind::Mod { .. } = item.kind {
-            self.is_exported.push(cx.access_levels.is_exported(item.hir_id));
+            self.is_exported.push(cx.access_levels.is_exported(item.hir_id()));
         }
     }
 
-    fn check_item_post(&mut self, _cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'tcx>) {
+    fn check_item_post(&mut self, _cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
         if let ItemKind::Mod { .. } = item.kind {
             self.is_exported.pop().expect("unbalanced check_item/check_item_post");
         }