author: name qpath consistently
This commit is contained in:
parent
e3d1e60ed9
commit
ce01346ac1
@ -569,7 +569,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
||||
ExprKind::Cast(expr, ty) => {
|
||||
let cast_pat = self.next("expr");
|
||||
let cast_ty = self.next("cast_ty");
|
||||
let qp_label = self.next("qp");
|
||||
let qp_label = self.next("qpath");
|
||||
|
||||
println!("Cast(ref {}, ref {}) = {};", cast_pat, cast_ty, current);
|
||||
|
||||
@ -717,7 +717,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
||||
self.visit_expr(index);
|
||||
},
|
||||
ExprKind::Path(ref path) => {
|
||||
let path_pat = self.next("path");
|
||||
let path_pat = self.next("qpath");
|
||||
|
||||
println!("Path(ref {}) = {};", path_pat, current);
|
||||
|
||||
@ -780,7 +780,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
||||
println!(" // unimplemented: `ExprKind::LlvmInlineAsm` is not further destructured at the moment");
|
||||
},
|
||||
ExprKind::Struct(path, fields, ref opt_base) => {
|
||||
let path_pat = self.next("path");
|
||||
let path_pat = self.next("qpath");
|
||||
let fields_pat = self.next("fields");
|
||||
|
||||
if let Some(base) = *opt_base {
|
||||
@ -895,7 +895,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
||||
println!(" if {}.as_str() == \"{}\";", name_pat, ident.as_str());
|
||||
},
|
||||
PatKind::Struct(ref path, fields, ignore) => {
|
||||
let path_pat = self.next("path");
|
||||
let path_pat = self.next("qpath");
|
||||
let fields_pat = self.next("fields");
|
||||
println!(
|
||||
"Struct(ref {}, ref {}, {}) = {};",
|
||||
@ -930,7 +930,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
||||
}
|
||||
},
|
||||
PatKind::TupleStruct(ref path, fields, skip_pos) => {
|
||||
let path_pat = self.next("path");
|
||||
let path_pat = self.next("qpath");
|
||||
let fields_pat = self.next("fields");
|
||||
|
||||
println!(
|
||||
@ -949,7 +949,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
||||
}
|
||||
},
|
||||
PatKind::Path(ref path) => {
|
||||
let path_pat = self.next("path");
|
||||
let path_pat = self.next("qpath");
|
||||
println!("Path(ref {}) = {};", path_pat, current);
|
||||
|
||||
self.current = path_pat;
|
||||
|
@ -2,8 +2,8 @@ if_chain! {
|
||||
if let StmtKind::Local(ref local) = stmt.kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let ExprKind::Cast(ref expr, ref cast_ty) = init.kind;
|
||||
if let TyKind::Path(ref qp) = cast_ty.kind;
|
||||
if match_qpath(qp, &["char"]);
|
||||
if let TyKind::Path(ref qpath) = cast_ty.kind;
|
||||
if match_qpath(qpath, &["char"]);
|
||||
if let ExprKind::Lit(ref lit) = expr.kind;
|
||||
if let LitKind::Int(69, LitIntType::Unsuffixed) = lit.node;
|
||||
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
|
||||
|
@ -15,8 +15,8 @@ if_chain! {
|
||||
if name1.as_str() == "_t";
|
||||
if let StmtKind::Semi(ref e, _) = block.stmts[2].kind
|
||||
if let ExprKind::Unary(UnOp::Neg, ref inner) = e.kind;
|
||||
if let ExprKind::Path(ref path) = inner.kind;
|
||||
if match_qpath(path, &["x"]);
|
||||
if let ExprKind::Path(ref qpath) = inner.kind;
|
||||
if match_qpath(qpath, &["x"]);
|
||||
if block.expr.is_none();
|
||||
then {
|
||||
// report your lint here
|
||||
@ -28,18 +28,18 @@ if_chain! {
|
||||
if let StmtKind::Local(ref local) = block.stmts[0].kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let ExprKind::Call(ref func, ref args) = init.kind;
|
||||
if let ExprKind::Path(ref path) = func.kind;
|
||||
if match_qpath(path, &["String", "new"]);
|
||||
if let ExprKind::Path(ref qpath) = func.kind;
|
||||
if match_qpath(qpath, &["String", "new"]);
|
||||
if args.len() == 0;
|
||||
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
|
||||
if name.as_str() == "expr";
|
||||
if let Some(trailing_expr) = &block.expr;
|
||||
if let ExprKind::Call(ref func1, ref args1) = trailing_expr.kind;
|
||||
if let ExprKind::Path(ref path1) = func1.kind;
|
||||
if match_qpath(path1, &["drop"]);
|
||||
if let ExprKind::Path(ref qpath1) = func1.kind;
|
||||
if match_qpath(qpath1, &["drop"]);
|
||||
if args1.len() == 1;
|
||||
if let ExprKind::Path(ref path2) = args1[0].kind;
|
||||
if match_qpath(path2, &["expr"]);
|
||||
if let ExprKind::Path(ref qpath2) = args1[0].kind;
|
||||
if match_qpath(qpath2, &["expr"]);
|
||||
then {
|
||||
// report your lint here
|
||||
}
|
||||
@ -49,8 +49,8 @@ if_chain! {
|
||||
if let FnRetTy::DefaultReturn(_) = fn_decl.output
|
||||
let body = cx.tcx.hir().body(body_id);
|
||||
if let ExprKind::Call(ref func, ref args) = body.value.kind;
|
||||
if let ExprKind::Path(ref path) = func.kind;
|
||||
if matches!(path, QPath::LangItem(LangItem::FromGenerator, _));
|
||||
if let ExprKind::Path(ref qpath) = func.kind;
|
||||
if matches!(qpath, QPath::LangItem(LangItem::FromGenerator, _));
|
||||
if args.len() == 1;
|
||||
if let ExprKind::Closure(CaptureBy::Value, ref fn_decl1, ref body_id1, _, Some(Movability::Static)) = args[0].kind
|
||||
if let FnRetTy::DefaultReturn(_) = fn_decl1.output
|
||||
|
@ -2,8 +2,8 @@ if_chain! {
|
||||
if let StmtKind::Local(ref local) = stmt.kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let ExprKind::Call(ref func, ref args) = init.kind;
|
||||
if let ExprKind::Path(ref path) = func.kind;
|
||||
if match_qpath(path, &["{{root}}", "std", "cmp", "min"]);
|
||||
if let ExprKind::Path(ref qpath) = func.kind;
|
||||
if match_qpath(qpath, &["{{root}}", "std", "cmp", "min"]);
|
||||
if args.len() == 2;
|
||||
if let ExprKind::Lit(ref lit) = args[0].kind;
|
||||
if let LitKind::Int(3, LitIntType::Unsuffixed) = lit.node;
|
||||
|
@ -34,8 +34,8 @@ if_chain! {
|
||||
if let PatKind::Lit(ref lit_expr) = let_pat.kind
|
||||
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
||||
if let LitKind::Bool(true) = lit.node;
|
||||
if let ExprKind::Path(ref path) = let_expr.kind;
|
||||
if match_qpath(path, &["a"]);
|
||||
if let ExprKind::Path(ref qpath) = let_expr.kind;
|
||||
if match_qpath(qpath, &["a"]);
|
||||
if let ExprKind::Block(ref block, ref label) = if_then.kind;
|
||||
if block.stmts.len() == 0;
|
||||
if block.expr.is_none();
|
||||
|
@ -2,11 +2,11 @@ if_chain! {
|
||||
if let StmtKind::Local(ref local) = stmt.kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let ExprKind::Call(ref func, ref args) = init.kind;
|
||||
if let ExprKind::Path(ref path) = func.kind;
|
||||
if match_qpath(path, &["std", "mem", "transmute"]);
|
||||
if let ExprKind::Path(ref qpath) = func.kind;
|
||||
if match_qpath(qpath, &["std", "mem", "transmute"]);
|
||||
if args.len() == 1;
|
||||
if let ExprKind::Path(ref path1) = args[0].kind;
|
||||
if match_qpath(path1, &["ZPTR"]);
|
||||
if let ExprKind::Path(ref qpath1) = args[0].kind;
|
||||
if match_qpath(qpath1, &["ZPTR"]);
|
||||
if let PatKind::Wild = local.pat.kind;
|
||||
then {
|
||||
// report your lint here
|
||||
|
@ -3,8 +3,8 @@ if_chain! {
|
||||
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
|
||||
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = pat.kind;
|
||||
if name.as_str() == "y";
|
||||
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
|
||||
if matches!(path, QPath::LangItem(LangItem::Range, _));
|
||||
if let ExprKind::Struct(ref qpath, ref fields, None) = arg.kind;
|
||||
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
||||
if fields.len() == 2;
|
||||
if fields[0].ident.name.as_str() == "start"
|
||||
if let ExprKind::Lit(ref lit) = fields[0].kind;
|
||||
@ -16,8 +16,8 @@ if_chain! {
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Local(ref local) = block.stmts[0].kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let ExprKind::Path(ref path1) = init.kind;
|
||||
if match_qpath(path1, &["y"]);
|
||||
if let ExprKind::Path(ref qpath1) = init.kind;
|
||||
if match_qpath(qpath1, &["y"]);
|
||||
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
|
||||
if name1.as_str() == "z";
|
||||
if block.expr.is_none();
|
||||
@ -29,8 +29,8 @@ if_chain! {
|
||||
if let ExprKind::DropTemps(ref expr) = expr.kind;
|
||||
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
|
||||
if let PatKind::Wild = pat.kind;
|
||||
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
|
||||
if matches!(path, QPath::LangItem(LangItem::Range, _));
|
||||
if let ExprKind::Struct(ref qpath, ref fields, None) = arg.kind;
|
||||
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
||||
if fields.len() == 2;
|
||||
if fields[0].ident.name.as_str() == "start"
|
||||
if let ExprKind::Lit(ref lit) = fields[0].kind;
|
||||
@ -51,8 +51,8 @@ if_chain! {
|
||||
if let ExprKind::DropTemps(ref expr) = expr.kind;
|
||||
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
|
||||
if let PatKind::Wild = pat.kind;
|
||||
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
|
||||
if matches!(path, QPath::LangItem(LangItem::Range, _));
|
||||
if let ExprKind::Struct(ref qpath, ref fields, None) = arg.kind;
|
||||
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
||||
if fields.len() == 2;
|
||||
if fields[0].ident.name.as_str() == "start"
|
||||
if let ExprKind::Lit(ref lit) = fields[0].kind;
|
||||
@ -73,8 +73,8 @@ if_chain! {
|
||||
}
|
||||
if_chain! {
|
||||
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr)
|
||||
if let ExprKind::Path(ref path) = condition.kind;
|
||||
if match_qpath(path, &["a"]);
|
||||
if let ExprKind::Path(ref qpath) = condition.kind;
|
||||
if match_qpath(qpath, &["a"]);
|
||||
if let ExprKind::Block(ref block, ref label) = body.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
|
||||
@ -89,8 +89,8 @@ if_chain! {
|
||||
if let PatKind::Lit(ref lit_expr) = let_pat.kind
|
||||
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
||||
if let LitKind::Bool(true) = lit.node;
|
||||
if let ExprKind::Path(ref path) = let_expr.kind;
|
||||
if match_qpath(path, &["a"]);
|
||||
if let ExprKind::Path(ref qpath) = let_expr.kind;
|
||||
if match_qpath(qpath, &["a"]);
|
||||
if let ExprKind::Block(ref block, ref label) = if_then.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
|
||||
|
@ -19,8 +19,8 @@ if_chain! {
|
||||
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local1.pat.kind;
|
||||
if name.as_str() == "x";
|
||||
if let Some(trailing_expr) = &block.expr;
|
||||
if let ExprKind::Path(ref path) = trailing_expr.kind;
|
||||
if match_qpath(path, &["x"]);
|
||||
if let ExprKind::Path(ref qpath) = trailing_expr.kind;
|
||||
if match_qpath(qpath, &["x"]);
|
||||
if let PatKind::Lit(ref lit_expr1) = arms[1].pat.kind
|
||||
if let ExprKind::Lit(ref lit4) = lit_expr1.kind;
|
||||
if let LitKind::Int(17, LitIntType::Unsuffixed) = lit4.node;
|
||||
|
@ -1,6 +1,6 @@
|
||||
if_chain! {
|
||||
if let ExprKind::Struct(ref path, ref fields, None) = expr.kind;
|
||||
if match_qpath(path, &["Test"]);
|
||||
if let ExprKind::Struct(ref qpath, ref fields, None) = expr.kind;
|
||||
if match_qpath(qpath, &["Test"]);
|
||||
if fields.len() == 1;
|
||||
if fields[0].ident.name.as_str() == "field"
|
||||
if let Some(higher::If { cond: cond, then: then, r#else: else_expr}) = higher::If::hir(fields[0])
|
||||
@ -21,8 +21,8 @@ if_chain! {
|
||||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let PatKind::Struct(ref path, ref fields, false) = arm.kind;
|
||||
if match_qpath(path, &["Test"]);
|
||||
if let PatKind::Struct(ref qpath, ref fields, false) = arm.kind;
|
||||
if match_qpath(qpath, &["Test"]);
|
||||
if fields.len() == 1;
|
||||
if fields[0].ident.name.as_str() == "field"
|
||||
if let PatKind::Lit(ref lit_expr) = fields[0].kind
|
||||
@ -36,8 +36,8 @@ if_chain! {
|
||||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let PatKind::TupleStruct(ref path, ref fields, None) = arm.kind;
|
||||
if match_qpath(path, &["TestTuple"]);
|
||||
if let PatKind::TupleStruct(ref qpath, ref fields, None) = arm.kind;
|
||||
if match_qpath(qpath, &["TestTuple"]);
|
||||
if fields.len() == 1;
|
||||
if let PatKind::Lit(ref lit_expr) = fields[0].kind
|
||||
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
||||
@ -53,8 +53,8 @@ if_chain! {
|
||||
if let ExprKind::MethodCall(ref method_name, ref args, _) = expr.kind;
|
||||
if method_name.ident.name.as_str() == test;
|
||||
if args.len() == 1;
|
||||
if let ExprKind::Path(ref path) = args[0].kind;
|
||||
if match_qpath(path, &["test_method_call"]);
|
||||
if let ExprKind::Path(ref qpath) = args[0].kind;
|
||||
if match_qpath(qpath, &["test_method_call"]);
|
||||
then {
|
||||
// report your lint here
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user