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;
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)) {
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 {
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);
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),