Skip to content

Commit ce01346

Browse files
committed
author: name qpath consistently
1 parent e3d1e60 commit ce01346

File tree

9 files changed

+48
-48
lines changed

9 files changed

+48
-48
lines changed

clippy_lints/src/utils/author.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
569569
ExprKind::Cast(expr, ty) => {
570570
let cast_pat = self.next("expr");
571571
let cast_ty = self.next("cast_ty");
572-
let qp_label = self.next("qp");
572+
let qp_label = self.next("qpath");
573573

574574
println!("Cast(ref {}, ref {}) = {};", cast_pat, cast_ty, current);
575575

@@ -717,7 +717,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
717717
self.visit_expr(index);
718718
},
719719
ExprKind::Path(ref path) => {
720-
let path_pat = self.next("path");
720+
let path_pat = self.next("qpath");
721721

722722
println!("Path(ref {}) = {};", path_pat, current);
723723

@@ -780,7 +780,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
780780
println!(" // unimplemented: `ExprKind::LlvmInlineAsm` is not further destructured at the moment");
781781
},
782782
ExprKind::Struct(path, fields, ref opt_base) => {
783-
let path_pat = self.next("path");
783+
let path_pat = self.next("qpath");
784784
let fields_pat = self.next("fields");
785785

786786
if let Some(base) = *opt_base {
@@ -895,7 +895,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
895895
println!(" if {}.as_str() == \"{}\";", name_pat, ident.as_str());
896896
},
897897
PatKind::Struct(ref path, fields, ignore) => {
898-
let path_pat = self.next("path");
898+
let path_pat = self.next("qpath");
899899
let fields_pat = self.next("fields");
900900
println!(
901901
"Struct(ref {}, ref {}, {}) = {};",
@@ -930,7 +930,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
930930
}
931931
},
932932
PatKind::TupleStruct(ref path, fields, skip_pos) => {
933-
let path_pat = self.next("path");
933+
let path_pat = self.next("qpath");
934934
let fields_pat = self.next("fields");
935935

936936
println!(
@@ -949,7 +949,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
949949
}
950950
},
951951
PatKind::Path(ref path) => {
952-
let path_pat = self.next("path");
952+
let path_pat = self.next("qpath");
953953
println!("Path(ref {}) = {};", path_pat, current);
954954

955955
self.current = path_pat;

tests/ui/author.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ if_chain! {
22
if let StmtKind::Local(ref local) = stmt.kind;
33
if let Some(ref init) = local.init;
44
if let ExprKind::Cast(ref expr, ref cast_ty) = init.kind;
5-
if let TyKind::Path(ref qp) = cast_ty.kind;
6-
if match_qpath(qp, &["char"]);
5+
if let TyKind::Path(ref qpath) = cast_ty.kind;
6+
if match_qpath(qpath, &["char"]);
77
if let ExprKind::Lit(ref lit) = expr.kind;
88
if let LitKind::Int(69, LitIntType::Unsuffixed) = lit.node;
99
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;

tests/ui/author/blocks.stdout

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ if_chain! {
1515
if name1.as_str() == "_t";
1616
if let StmtKind::Semi(ref e, _) = block.stmts[2].kind
1717
if let ExprKind::Unary(UnOp::Neg, ref inner) = e.kind;
18-
if let ExprKind::Path(ref path) = inner.kind;
19-
if match_qpath(path, &["x"]);
18+
if let ExprKind::Path(ref qpath) = inner.kind;
19+
if match_qpath(qpath, &["x"]);
2020
if block.expr.is_none();
2121
then {
2222
// report your lint here
@@ -28,18 +28,18 @@ if_chain! {
2828
if let StmtKind::Local(ref local) = block.stmts[0].kind;
2929
if let Some(ref init) = local.init;
3030
if let ExprKind::Call(ref func, ref args) = init.kind;
31-
if let ExprKind::Path(ref path) = func.kind;
32-
if match_qpath(path, &["String", "new"]);
31+
if let ExprKind::Path(ref qpath) = func.kind;
32+
if match_qpath(qpath, &["String", "new"]);
3333
if args.len() == 0;
3434
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
3535
if name.as_str() == "expr";
3636
if let Some(trailing_expr) = &block.expr;
3737
if let ExprKind::Call(ref func1, ref args1) = trailing_expr.kind;
38-
if let ExprKind::Path(ref path1) = func1.kind;
39-
if match_qpath(path1, &["drop"]);
38+
if let ExprKind::Path(ref qpath1) = func1.kind;
39+
if match_qpath(qpath1, &["drop"]);
4040
if args1.len() == 1;
41-
if let ExprKind::Path(ref path2) = args1[0].kind;
42-
if match_qpath(path2, &["expr"]);
41+
if let ExprKind::Path(ref qpath2) = args1[0].kind;
42+
if match_qpath(qpath2, &["expr"]);
4343
then {
4444
// report your lint here
4545
}
@@ -49,8 +49,8 @@ if_chain! {
4949
if let FnRetTy::DefaultReturn(_) = fn_decl.output
5050
let body = cx.tcx.hir().body(body_id);
5151
if let ExprKind::Call(ref func, ref args) = body.value.kind;
52-
if let ExprKind::Path(ref path) = func.kind;
53-
if matches!(path, QPath::LangItem(LangItem::FromGenerator, _));
52+
if let ExprKind::Path(ref qpath) = func.kind;
53+
if matches!(qpath, QPath::LangItem(LangItem::FromGenerator, _));
5454
if args.len() == 1;
5555
if let ExprKind::Closure(CaptureBy::Value, ref fn_decl1, ref body_id1, _, Some(Movability::Static)) = args[0].kind
5656
if let FnRetTy::DefaultReturn(_) = fn_decl1.output

tests/ui/author/call.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ if_chain! {
22
if let StmtKind::Local(ref local) = stmt.kind;
33
if let Some(ref init) = local.init;
44
if let ExprKind::Call(ref func, ref args) = init.kind;
5-
if let ExprKind::Path(ref path) = func.kind;
6-
if match_qpath(path, &["{{root}}", "std", "cmp", "min"]);
5+
if let ExprKind::Path(ref qpath) = func.kind;
6+
if match_qpath(qpath, &["{{root}}", "std", "cmp", "min"]);
77
if args.len() == 2;
88
if let ExprKind::Lit(ref lit) = args[0].kind;
99
if let LitKind::Int(3, LitIntType::Unsuffixed) = lit.node;

tests/ui/author/if.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ if_chain! {
3434
if let PatKind::Lit(ref lit_expr) = let_pat.kind
3535
if let ExprKind::Lit(ref lit) = lit_expr.kind;
3636
if let LitKind::Bool(true) = lit.node;
37-
if let ExprKind::Path(ref path) = let_expr.kind;
38-
if match_qpath(path, &["a"]);
37+
if let ExprKind::Path(ref qpath) = let_expr.kind;
38+
if match_qpath(qpath, &["a"]);
3939
if let ExprKind::Block(ref block, ref label) = if_then.kind;
4040
if block.stmts.len() == 0;
4141
if block.expr.is_none();

tests/ui/author/issue_3849.stdout

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ if_chain! {
22
if let StmtKind::Local(ref local) = stmt.kind;
33
if let Some(ref init) = local.init;
44
if let ExprKind::Call(ref func, ref args) = init.kind;
5-
if let ExprKind::Path(ref path) = func.kind;
6-
if match_qpath(path, &["std", "mem", "transmute"]);
5+
if let ExprKind::Path(ref qpath) = func.kind;
6+
if match_qpath(qpath, &["std", "mem", "transmute"]);
77
if args.len() == 1;
8-
if let ExprKind::Path(ref path1) = args[0].kind;
9-
if match_qpath(path1, &["ZPTR"]);
8+
if let ExprKind::Path(ref qpath1) = args[0].kind;
9+
if match_qpath(qpath1, &["ZPTR"]);
1010
if let PatKind::Wild = local.pat.kind;
1111
then {
1212
// report your lint here

tests/ui/author/loop.stdout

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ if_chain! {
33
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
44
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = pat.kind;
55
if name.as_str() == "y";
6-
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
7-
if matches!(path, QPath::LangItem(LangItem::Range, _));
6+
if let ExprKind::Struct(ref qpath, ref fields, None) = arg.kind;
7+
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
88
if fields.len() == 2;
99
if fields[0].ident.name.as_str() == "start"
1010
if let ExprKind::Lit(ref lit) = fields[0].kind;
@@ -16,8 +16,8 @@ if_chain! {
1616
if block.stmts.len() == 1;
1717
if let StmtKind::Local(ref local) = block.stmts[0].kind;
1818
if let Some(ref init) = local.init;
19-
if let ExprKind::Path(ref path1) = init.kind;
20-
if match_qpath(path1, &["y"]);
19+
if let ExprKind::Path(ref qpath1) = init.kind;
20+
if match_qpath(qpath1, &["y"]);
2121
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
2222
if name1.as_str() == "z";
2323
if block.expr.is_none();
@@ -29,8 +29,8 @@ if_chain! {
2929
if let ExprKind::DropTemps(ref expr) = expr.kind;
3030
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
3131
if let PatKind::Wild = pat.kind;
32-
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
33-
if matches!(path, QPath::LangItem(LangItem::Range, _));
32+
if let ExprKind::Struct(ref qpath, ref fields, None) = arg.kind;
33+
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
3434
if fields.len() == 2;
3535
if fields[0].ident.name.as_str() == "start"
3636
if let ExprKind::Lit(ref lit) = fields[0].kind;
@@ -51,8 +51,8 @@ if_chain! {
5151
if let ExprKind::DropTemps(ref expr) = expr.kind;
5252
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, ..}) = higher::ForLoop::hir(expr)
5353
if let PatKind::Wild = pat.kind;
54-
if let ExprKind::Struct(ref path, ref fields, None) = arg.kind;
55-
if matches!(path, QPath::LangItem(LangItem::Range, _));
54+
if let ExprKind::Struct(ref qpath, ref fields, None) = arg.kind;
55+
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
5656
if fields.len() == 2;
5757
if fields[0].ident.name.as_str() == "start"
5858
if let ExprKind::Lit(ref lit) = fields[0].kind;
@@ -73,8 +73,8 @@ if_chain! {
7373
}
7474
if_chain! {
7575
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr)
76-
if let ExprKind::Path(ref path) = condition.kind;
77-
if match_qpath(path, &["a"]);
76+
if let ExprKind::Path(ref qpath) = condition.kind;
77+
if match_qpath(qpath, &["a"]);
7878
if let ExprKind::Block(ref block, ref label) = body.kind;
7979
if block.stmts.len() == 1;
8080
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
@@ -89,8 +89,8 @@ if_chain! {
8989
if let PatKind::Lit(ref lit_expr) = let_pat.kind
9090
if let ExprKind::Lit(ref lit) = lit_expr.kind;
9191
if let LitKind::Bool(true) = lit.node;
92-
if let ExprKind::Path(ref path) = let_expr.kind;
93-
if match_qpath(path, &["a"]);
92+
if let ExprKind::Path(ref qpath) = let_expr.kind;
93+
if match_qpath(qpath, &["a"]);
9494
if let ExprKind::Block(ref block, ref label) = if_then.kind;
9595
if block.stmts.len() == 1;
9696
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind

tests/ui/author/matches.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ if_chain! {
1919
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local1.pat.kind;
2020
if name.as_str() == "x";
2121
if let Some(trailing_expr) = &block.expr;
22-
if let ExprKind::Path(ref path) = trailing_expr.kind;
23-
if match_qpath(path, &["x"]);
22+
if let ExprKind::Path(ref qpath) = trailing_expr.kind;
23+
if match_qpath(qpath, &["x"]);
2424
if let PatKind::Lit(ref lit_expr1) = arms[1].pat.kind
2525
if let ExprKind::Lit(ref lit4) = lit_expr1.kind;
2626
if let LitKind::Int(17, LitIntType::Unsuffixed) = lit4.node;

tests/ui/author/struct.stdout

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
if_chain! {
2-
if let ExprKind::Struct(ref path, ref fields, None) = expr.kind;
3-
if match_qpath(path, &["Test"]);
2+
if let ExprKind::Struct(ref qpath, ref fields, None) = expr.kind;
3+
if match_qpath(qpath, &["Test"]);
44
if fields.len() == 1;
55
if fields[0].ident.name.as_str() == "field"
66
if let Some(higher::If { cond: cond, then: then, r#else: else_expr}) = higher::If::hir(fields[0])
@@ -21,8 +21,8 @@ if_chain! {
2121
}
2222
}
2323
if_chain! {
24-
if let PatKind::Struct(ref path, ref fields, false) = arm.kind;
25-
if match_qpath(path, &["Test"]);
24+
if let PatKind::Struct(ref qpath, ref fields, false) = arm.kind;
25+
if match_qpath(qpath, &["Test"]);
2626
if fields.len() == 1;
2727
if fields[0].ident.name.as_str() == "field"
2828
if let PatKind::Lit(ref lit_expr) = fields[0].kind
@@ -36,8 +36,8 @@ if_chain! {
3636
}
3737
}
3838
if_chain! {
39-
if let PatKind::TupleStruct(ref path, ref fields, None) = arm.kind;
40-
if match_qpath(path, &["TestTuple"]);
39+
if let PatKind::TupleStruct(ref qpath, ref fields, None) = arm.kind;
40+
if match_qpath(qpath, &["TestTuple"]);
4141
if fields.len() == 1;
4242
if let PatKind::Lit(ref lit_expr) = fields[0].kind
4343
if let ExprKind::Lit(ref lit) = lit_expr.kind;
@@ -53,8 +53,8 @@ if_chain! {
5353
if let ExprKind::MethodCall(ref method_name, ref args, _) = expr.kind;
5454
if method_name.ident.name.as_str() == test;
5555
if args.len() == 1;
56-
if let ExprKind::Path(ref path) = args[0].kind;
57-
if match_qpath(path, &["test_method_call"]);
56+
if let ExprKind::Path(ref qpath) = args[0].kind;
57+
if match_qpath(qpath, &["test_method_call"]);
5858
then {
5959
// report your lint here
6060
}

0 commit comments

Comments
 (0)