]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/clippy_lints/src/utils/inspector.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / tools / clippy / clippy_lints / src / utils / inspector.rs
index 4665eeeff7b21c2264c1469d0966cad2e7c780f7..e97983a2e1451d373e77609e8f13f456f7dbbfde 100644 (file)
@@ -8,10 +8,11 @@ use rustc_session::Session;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
 declare_clippy_lint! {
-    /// **What it does:** Dumps every ast/hir node which has the `#[clippy::dump]`
+    /// ### What it does
+    /// Dumps every ast/hir node which has the `#[clippy::dump]`
     /// attribute
     ///
-    /// **Example:**
+    /// ### Example
     /// ```rust,ignore
     /// #[clippy::dump]
     /// extern crate foo;
@@ -65,28 +66,6 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector {
             hir::ImplItemKind::TyAlias(_) => println!("associated type"),
         }
     }
-    // fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx
-    // hir::TraitItem) {
-    // if !has_attr(&item.attrs) {
-    // return;
-    // }
-    // }
-    //
-    // fn check_variant(&mut self, cx: &LateContext<'tcx>, var: &'tcx
-    // hir::Variant, _:
-    // &hir::Generics) {
-    // if !has_attr(&var.node.attrs) {
-    // return;
-    // }
-    // }
-    //
-    // fn check_field_def(&mut self, cx: &LateContext<'tcx>, field: &'tcx
-    // hir::FieldDef) {
-    // if !has_attr(&field.attrs) {
-    // return;
-    // }
-    // }
-    //
 
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
         if !has_attr(cx.sess(), cx.tcx.hir().attrs(expr.hir_id)) {
@@ -126,13 +105,6 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector {
             hir::StmtKind::Expr(e) | hir::StmtKind::Semi(e) => print_expr(cx, e, 0),
         }
     }
-    // fn check_foreign_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx
-    // hir::ForeignItem) {
-    // if !has_attr(&item.attrs) {
-    // return;
-    // }
-    // }
-    //
 }
 
 fn has_attr(sess: &Session, attrs: &[Attribute]) -> bool {
@@ -170,6 +142,10 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
                 print_expr(cx, arg, indent + 1);
             }
         },
+        hir::ExprKind::Let(ref pat, ref expr, _) => {
+            print_pat(cx, pat, indent + 1);
+            print_expr(cx, expr, indent + 1);
+        },
         hir::ExprKind::MethodCall(path, _, args, _) => {
             println!("{}MethodCall", ind);
             println!("{}method name: {}", ind, path.ident.name);
@@ -405,6 +381,13 @@ fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
             let item_ty = cx.tcx.type_of(did);
             println!("function of type {:#?}", item_ty);
         },
+        hir::ItemKind::Macro(ref macro_def) => {
+            if macro_def.macro_rules {
+                println!("macro introduced by `macro_rules!`");
+            } else {
+                println!("macro introduced by `macro`");
+            }
+        },
         hir::ItemKind::Mod(..) => println!("module"),
         hir::ItemKind::ForeignMod { abi, .. } => println!("foreign module with abi: {}", abi),
         hir::ItemKind::GlobalAsm(asm) => println!("global asm: {:?}", asm),