mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
author: Remove needless ref
s
This commit is contained in:
parent
a806ce79b6
commit
72d7b9c097
10 changed files with 151 additions and 169 deletions
|
@ -196,7 +196,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
if let Some(label) = label {
|
||||
let label_bind = self.next("label");
|
||||
|
||||
println!(" if let Some(ref {}) = {};", label_bind, self.current);
|
||||
println!(" if let Some({}) = {};", label_bind, self.current);
|
||||
|
||||
let label_name_bind = self.next("label_name");
|
||||
let label_name = label.ident.name;
|
||||
|
@ -242,10 +242,10 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
println!(" if let LitKind::ByteStr(ref {}) = {}.node;", vec_pat, lit_pat);
|
||||
println!(" if let [{:?}] = **{};", vec, vec_pat);
|
||||
},
|
||||
LitKind::Str(ref text, _) => {
|
||||
LitKind::Str(text, _) => {
|
||||
let str_pat = self.next("s");
|
||||
|
||||
println!(" if let LitKind::Str(ref {}, _) = {}.node;", str_pat, lit_pat);
|
||||
println!(" if let LitKind::Str({}, _) = {}.node;", str_pat, lit_pat);
|
||||
println!(" if {}.as_str() == {:?};", str_pat, &*text.as_str());
|
||||
},
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
let arms_pat = self.next("arms");
|
||||
|
||||
println!(
|
||||
"Match(ref {}, ref {}, MatchSource::{:?}) = {};",
|
||||
"Match({}, {}, MatchSource::{:?}) = {};",
|
||||
expr_pat, arms_pat, des, current
|
||||
);
|
||||
|
||||
|
@ -269,16 +269,16 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
self.current = format!("{}[{}].pat", arms_pat, i);
|
||||
self.visit_pat(arm.pat);
|
||||
|
||||
if let Some(ref guard) = arm.guard {
|
||||
if let Some(guard) = &arm.guard {
|
||||
let guard_pat = self.next("guard");
|
||||
|
||||
println!(" if let Some(ref {}) = {}[{}].guard;", guard_pat, arms_pat, i);
|
||||
println!(" if let Some({}) = &{}[{}].guard;", guard_pat, arms_pat, i);
|
||||
|
||||
match guard {
|
||||
hir::Guard::If(if_expr) => {
|
||||
let if_expr_pat = self.next("expr");
|
||||
|
||||
println!(" if let Guard::If(ref {}) = {};", if_expr_pat, guard_pat);
|
||||
println!(" if let Guard::If({}) = {};", if_expr_pat, guard_pat);
|
||||
|
||||
self.current = if_expr_pat;
|
||||
self.visit_expr(if_expr);
|
||||
|
@ -288,7 +288,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
let if_let_expr_pat = self.next("expr");
|
||||
|
||||
println!(
|
||||
" if let Guard::IfLet(ref {}, ref {}) = {};",
|
||||
" if let Guard::IfLet({}, {}) = {};",
|
||||
if_let_pat_pat, if_let_expr_pat, guard_pat
|
||||
);
|
||||
|
||||
|
@ -461,7 +461,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let let_pat = self.next("pat");
|
||||
let let_expr = self.next("expr");
|
||||
|
||||
println!("Let(ref {}, ref {}, _) = {};", let_pat, let_expr, current);
|
||||
println!("Let({}, {}, _) = {};", let_pat, let_expr, current);
|
||||
|
||||
self.current = let_expr;
|
||||
self.visit_expr(expr);
|
||||
|
@ -472,7 +472,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
ExprKind::Box(inner) => {
|
||||
let inner_pat = self.next("inner");
|
||||
|
||||
println!("Box(ref {}) = {};", inner_pat, current);
|
||||
println!("Box({}) = {};", inner_pat, current);
|
||||
|
||||
self.current = inner_pat;
|
||||
self.visit_expr(inner);
|
||||
|
@ -480,7 +480,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
ExprKind::Array(elements) => {
|
||||
let elements_pat = self.next("elements");
|
||||
|
||||
println!("Array(ref {}) = {};", elements_pat, current);
|
||||
println!("Array({}) = {};", elements_pat, current);
|
||||
|
||||
println!(" if {}.len() == {};", elements_pat, elements.len());
|
||||
|
||||
|
@ -493,7 +493,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let func_pat = self.next("func");
|
||||
let args_pat = self.next("args");
|
||||
|
||||
println!("Call(ref {}, ref {}) = {};", func_pat, args_pat, current);
|
||||
println!("Call({}, {}) = {};", func_pat, args_pat, current);
|
||||
|
||||
self.current = func_pat;
|
||||
self.visit_expr(func);
|
||||
|
@ -509,10 +509,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let method_name_pat = self.next("method_name");
|
||||
let args_pat = self.next("args");
|
||||
|
||||
println!(
|
||||
"MethodCall(ref {}, ref {}, _) = {};",
|
||||
method_name_pat, args_pat, current
|
||||
);
|
||||
println!("MethodCall({}, _, {}, _) = {};", method_name_pat, args_pat, current);
|
||||
|
||||
println!(
|
||||
" if {}.ident.name.as_str() == {};",
|
||||
|
@ -530,7 +527,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
ExprKind::Tup(elements) => {
|
||||
let elements_pat = self.next("elements");
|
||||
|
||||
println!("Tup(ref {}) = {};", elements_pat, current);
|
||||
println!("Tup({}) = {};", elements_pat, current);
|
||||
|
||||
println!(" if {}.len() == {};", elements_pat, elements.len());
|
||||
|
||||
|
@ -539,15 +536,12 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
self.visit_expr(element);
|
||||
}
|
||||
},
|
||||
ExprKind::Binary(ref op, left, right) => {
|
||||
ExprKind::Binary(op, left, right) => {
|
||||
let op_pat = self.next("op");
|
||||
let left_pat = self.next("left");
|
||||
let right_pat = self.next("right");
|
||||
|
||||
println!(
|
||||
"Binary(ref {}, ref {}, ref {}) = {};",
|
||||
op_pat, left_pat, right_pat, current
|
||||
);
|
||||
println!("Binary({}, {}, {}) = {};", op_pat, left_pat, right_pat, current);
|
||||
|
||||
println!(" if BinOpKind::{:?} == {}.node;", op.node, op_pat);
|
||||
|
||||
|
@ -557,10 +551,10 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
self.current = right_pat;
|
||||
self.visit_expr(right);
|
||||
},
|
||||
ExprKind::Unary(ref op, inner) => {
|
||||
ExprKind::Unary(op, inner) => {
|
||||
let inner_pat = self.next("inner");
|
||||
|
||||
println!("Unary(UnOp::{:?}, ref {}) = {};", op, inner_pat, current);
|
||||
println!("Unary(UnOp::{:?}, {}) = {};", op, inner_pat, current);
|
||||
|
||||
self.current = inner_pat;
|
||||
self.visit_expr(inner);
|
||||
|
@ -571,7 +565,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let cast_ty = self.next("cast_ty");
|
||||
let qp_label = self.next("qpath");
|
||||
|
||||
println!("Cast(ref {}, ref {}) = {};", cast_pat, cast_ty, current);
|
||||
println!("Cast({}, {}) = {};", cast_pat, cast_ty, current);
|
||||
|
||||
if let TyKind::Path(ref qp) = ty.kind {
|
||||
println!(" if let TyKind::Path(ref {}) = {}.kind;", qp_label, cast_ty);
|
||||
|
@ -586,7 +580,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
ExprKind::Type(expr, _ty) => {
|
||||
let cast_pat = self.next("expr");
|
||||
|
||||
println!("Type(ref {}, _) = {};", cast_pat, current);
|
||||
println!("Type({}, _) = {};", cast_pat, current);
|
||||
|
||||
self.current = cast_pat;
|
||||
self.visit_expr(expr);
|
||||
|
@ -596,7 +590,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let label_pat = self.next("label");
|
||||
|
||||
println!(
|
||||
"Loop(ref {}, ref {}, LoopSource::{:?}, _) = {};",
|
||||
"Loop({}, {}, LoopSource::{:?}, _) = {};",
|
||||
body_pat, label_pat, des, current
|
||||
);
|
||||
|
||||
|
@ -626,7 +620,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let body_id_pat = self.next("body_id");
|
||||
|
||||
println!(
|
||||
"Closure({}, ref {}, ref {}, _, {}) = {};",
|
||||
"Closure({}, {}, {}, _, {}) = {};",
|
||||
capture_by, fn_decl_pat, body_id_pat, movability, current
|
||||
);
|
||||
println!(" if let {} = {}.output;", ret_ty, fn_decl_pat);
|
||||
|
@ -644,7 +638,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
ExprKind::Yield(sub, source) => {
|
||||
let sub_pat = self.next("sub");
|
||||
|
||||
println!("Yield(ref sub, YieldSource::{:?}) = {};", source, current);
|
||||
println!("Yield(sub, YieldSource::{:?}) = {};", source, current);
|
||||
|
||||
self.current = sub_pat;
|
||||
self.visit_expr(sub);
|
||||
|
@ -653,7 +647,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let block_pat = self.next("block");
|
||||
let label_pat = self.next("label");
|
||||
|
||||
println!("Block(ref {}, ref {}) = {};", block_pat, label_pat, current);
|
||||
println!("Block({}, {}) = {};", block_pat, label_pat, current);
|
||||
|
||||
self.current = block_pat;
|
||||
self.visit_block(block);
|
||||
|
@ -665,10 +659,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let target_pat = self.next("target");
|
||||
let value_pat = self.next("value");
|
||||
|
||||
println!(
|
||||
"Assign(ref {}, ref {}, ref _span) = {};",
|
||||
target_pat, value_pat, current
|
||||
);
|
||||
println!("Assign({}, {}, _span) = {};", target_pat, value_pat, current);
|
||||
|
||||
self.current = target_pat;
|
||||
self.visit_expr(target);
|
||||
|
@ -676,15 +667,12 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
self.current = value_pat;
|
||||
self.visit_expr(value);
|
||||
},
|
||||
ExprKind::AssignOp(ref op, target, value) => {
|
||||
ExprKind::AssignOp(op, target, value) => {
|
||||
let op_pat = self.next("op");
|
||||
let target_pat = self.next("target");
|
||||
let value_pat = self.next("value");
|
||||
|
||||
println!(
|
||||
"AssignOp(ref {}, ref {}, ref {}) = {};",
|
||||
op_pat, target_pat, value_pat, current
|
||||
);
|
||||
println!("AssignOp({}, {}, {}) = {};", op_pat, target_pat, value_pat, current);
|
||||
|
||||
println!(" if BinOpKind::{:?} == {}.node;", op.node, op_pat);
|
||||
|
||||
|
@ -694,11 +682,11 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
self.current = value_pat;
|
||||
self.visit_expr(value);
|
||||
},
|
||||
ExprKind::Field(object, ref field_ident) => {
|
||||
ExprKind::Field(object, field_ident) => {
|
||||
let obj_pat = self.next("object");
|
||||
let field_name_pat = self.next("field_name");
|
||||
|
||||
println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current);
|
||||
println!("Field({}, {}) = {};", obj_pat, field_name_pat, current);
|
||||
println!(" if {}.as_str() == {:?};", field_name_pat, field_ident.as_str());
|
||||
|
||||
self.current = obj_pat;
|
||||
|
@ -708,7 +696,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let object_pat = self.next("object");
|
||||
let index_pat = self.next("index");
|
||||
|
||||
println!("Index(ref {}, ref {}) = {};", object_pat, index_pat, current);
|
||||
println!("Index({}, {}) = {};", object_pat, index_pat, current);
|
||||
|
||||
self.current = object_pat;
|
||||
self.visit_expr(object);
|
||||
|
@ -728,42 +716,42 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let inner_pat = self.next("inner");
|
||||
|
||||
println!(
|
||||
"AddrOf(BorrowKind::{:?}, Mutability::{:?}, ref {}) = {};",
|
||||
"AddrOf(BorrowKind::{:?}, Mutability::{:?}, {}) = {};",
|
||||
kind, mutability, inner_pat, current
|
||||
);
|
||||
|
||||
self.current = inner_pat;
|
||||
self.visit_expr(inner);
|
||||
},
|
||||
ExprKind::Break(ref destination, ref opt_value) => {
|
||||
ExprKind::Break(destination, opt_value) => {
|
||||
let destination_pat = self.next("destination");
|
||||
|
||||
if let Some(value) = *opt_value {
|
||||
if let Some(value) = opt_value {
|
||||
let value_pat = self.next("value");
|
||||
|
||||
println!("Break(ref {}, Some(ref {})) = {};", destination_pat, value_pat, current);
|
||||
println!("Break({}, Some({})) = {};", destination_pat, value_pat, current);
|
||||
|
||||
self.current = value_pat;
|
||||
self.visit_expr(value);
|
||||
} else {
|
||||
println!("Break(ref {}, None) = {};", destination_pat, current);
|
||||
println!("Break({}, None) = {};", destination_pat, current);
|
||||
}
|
||||
|
||||
self.current = format!("{}.label", destination_pat);
|
||||
self.print_label(destination.label);
|
||||
},
|
||||
ExprKind::Continue(ref destination) => {
|
||||
ExprKind::Continue(destination) => {
|
||||
let destination_pat = self.next("destination");
|
||||
println!("Continue(ref {}) = {};", destination_pat, current);
|
||||
println!("Continue({}) = {};", destination_pat, current);
|
||||
|
||||
self.current = format!("{}.label", destination_pat);
|
||||
self.print_label(destination.label);
|
||||
},
|
||||
ExprKind::Ret(ref opt_value) => {
|
||||
if let Some(value) = *opt_value {
|
||||
ExprKind::Ret(opt_value) => {
|
||||
if let Some(value) = opt_value {
|
||||
let value_pat = self.next("value");
|
||||
|
||||
println!("Ret(Some(ref {})) = {};", value_pat, current);
|
||||
println!("Ret(Some({})) = {};", value_pat, current);
|
||||
|
||||
self.current = value_pat;
|
||||
self.visit_expr(value);
|
||||
|
@ -779,22 +767,22 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
println!("LlvmInlineAsm(_) = {};", current);
|
||||
println!(" // unimplemented: `ExprKind::LlvmInlineAsm` is not further destructured at the moment");
|
||||
},
|
||||
ExprKind::Struct(path, fields, ref opt_base) => {
|
||||
ExprKind::Struct(path, fields, opt_base) => {
|
||||
let path_pat = self.next("qpath");
|
||||
let fields_pat = self.next("fields");
|
||||
|
||||
if let Some(base) = *opt_base {
|
||||
if let Some(base) = opt_base {
|
||||
let base_pat = self.next("base");
|
||||
|
||||
println!(
|
||||
"Struct(ref {}, ref {}, Some(ref {})) = {};",
|
||||
"Struct({}, {}, Some({})) = {};",
|
||||
path_pat, fields_pat, base_pat, current
|
||||
);
|
||||
|
||||
self.current = base_pat;
|
||||
self.visit_expr(base);
|
||||
} else {
|
||||
println!("Struct(ref {}, ref {}, None) = {};", path_pat, fields_pat, current);
|
||||
println!("Struct({}, {}, None) = {};", path_pat, fields_pat, current);
|
||||
}
|
||||
|
||||
self.current = path_pat;
|
||||
|
@ -823,7 +811,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let value_pat = self.next("value");
|
||||
let length_pat = self.next("length");
|
||||
|
||||
println!("Repeat(ref {}, ref {}) = {};", value_pat, length_pat, current);
|
||||
println!("Repeat({}, {}) = {};", value_pat, length_pat, current);
|
||||
|
||||
self.current = value_pat;
|
||||
self.visit_expr(value);
|
||||
|
@ -840,7 +828,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
ExprKind::DropTemps(expr) => {
|
||||
let expr_pat = self.next("expr");
|
||||
|
||||
println!("DropTemps(ref {}) = {};", expr_pat, current);
|
||||
println!("DropTemps({}) = {};", expr_pat, current);
|
||||
|
||||
self.current = expr_pat;
|
||||
self.visit_expr(expr);
|
||||
|
@ -860,7 +848,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
|
||||
if let Some(expr) = block.expr {
|
||||
self.current = self.next("trailing_expr");
|
||||
println!(" if let Some({}) = &{}.expr;", self.current, block_name);
|
||||
println!(" if let Some({}) = {}.expr;", self.current, block_name);
|
||||
self.visit_expr(expr);
|
||||
} else {
|
||||
println!(" if {}.expr.is_none();", block_name);
|
||||
|
@ -874,15 +862,15 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
|
||||
match pat.kind {
|
||||
PatKind::Wild => println!("Wild = {};", current),
|
||||
PatKind::Binding(anno, .., ident, ref sub) => {
|
||||
PatKind::Binding(anno, .., ident, sub) => {
|
||||
let anno_pat = &format!("BindingAnnotation::{:?}", anno);
|
||||
let name_pat = self.next("name");
|
||||
|
||||
if let Some(sub) = *sub {
|
||||
if let Some(sub) = sub {
|
||||
let sub_pat = self.next("sub");
|
||||
|
||||
println!(
|
||||
"Binding({}, _, {}, Some(ref {})) = {};",
|
||||
"Binding({}, _, {}, Some({})) = {};",
|
||||
anno_pat, name_pat, sub_pat, current
|
||||
);
|
||||
|
||||
|
@ -897,10 +885,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
PatKind::Struct(ref path, fields, ignore) => {
|
||||
let path_pat = self.next("qpath");
|
||||
let fields_pat = self.next("fields");
|
||||
println!(
|
||||
"Struct(ref {}, ref {}, {}) = {};",
|
||||
path_pat, fields_pat, ignore, current
|
||||
);
|
||||
println!("Struct(ref {}, {}, {}) = {};", path_pat, fields_pat, ignore, current);
|
||||
|
||||
self.current = path_pat;
|
||||
self.print_qpath(path);
|
||||
|
@ -921,7 +906,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
},
|
||||
PatKind::Or(fields) => {
|
||||
let fields_pat = self.next("fields");
|
||||
println!("Or(ref {}) = {};", fields_pat, current);
|
||||
println!("Or({}) = {};", fields_pat, current);
|
||||
println!(" if {}.len() == {};", fields_pat, fields.len());
|
||||
|
||||
for (i, field) in fields.iter().enumerate() {
|
||||
|
@ -934,7 +919,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
let fields_pat = self.next("fields");
|
||||
|
||||
println!(
|
||||
"TupleStruct(ref {}, ref {}, {:?}) = {};",
|
||||
"TupleStruct(ref {}, {}, {:?}) = {};",
|
||||
path_pat, fields_pat, skip_pos, current
|
||||
);
|
||||
|
||||
|
@ -957,7 +942,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
},
|
||||
PatKind::Tuple(fields, skip_pos) => {
|
||||
let fields_pat = self.next("fields");
|
||||
println!("Tuple(ref {}, {:?}) = {};", fields_pat, skip_pos, current);
|
||||
println!("Tuple({}, {:?}) = {};", fields_pat, skip_pos, current);
|
||||
println!(" if {}.len() == {};", fields_pat, fields.len());
|
||||
|
||||
for (i, field) in fields.iter().enumerate() {
|
||||
|
@ -967,31 +952,31 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
},
|
||||
PatKind::Box(pat) => {
|
||||
let pat_pat = self.next("pat");
|
||||
println!("Box(ref {}) = {};", pat_pat, current);
|
||||
println!("Box({}) = {};", pat_pat, current);
|
||||
|
||||
self.current = pat_pat;
|
||||
self.visit_pat(pat);
|
||||
},
|
||||
PatKind::Ref(pat, muta) => {
|
||||
let pat_pat = self.next("pat");
|
||||
println!("Ref(ref {}, Mutability::{:?}) = {};", pat_pat, muta, current);
|
||||
println!("Ref({}, Mutability::{:?}) = {};", pat_pat, muta, current);
|
||||
|
||||
self.current = pat_pat;
|
||||
self.visit_pat(pat);
|
||||
},
|
||||
PatKind::Lit(lit_expr) => {
|
||||
let lit_expr_pat = self.next("lit_expr");
|
||||
println!("Lit(ref {}) = {};", lit_expr_pat, current);
|
||||
println!("Lit({}) = {};", lit_expr_pat, current);
|
||||
|
||||
self.current = lit_expr_pat;
|
||||
self.visit_expr(lit_expr);
|
||||
},
|
||||
PatKind::Range(ref start, ref end, end_kind) => {
|
||||
PatKind::Range(start, end, end_kind) => {
|
||||
let start_pat = self.next("start");
|
||||
let end_pat = self.next("end");
|
||||
|
||||
println!(
|
||||
"Range(ref {}, ref {}, RangeEnd::{:?}) = {};",
|
||||
"Range({}, {}, RangeEnd::{:?}) = {};",
|
||||
start_pat, end_pat, end_kind, current
|
||||
);
|
||||
|
||||
|
@ -1001,20 +986,17 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
self.current = end_pat;
|
||||
walk_list!(self, visit_expr, end);
|
||||
},
|
||||
PatKind::Slice(start, ref middle, end) => {
|
||||
PatKind::Slice(start, middle, end) => {
|
||||
let start_pat = self.next("start");
|
||||
let end_pat = self.next("end");
|
||||
|
||||
if let Some(middle) = middle {
|
||||
let middle_pat = self.next("middle");
|
||||
println!(
|
||||
"Slice(ref {}, Some(ref {}), ref {}) = {};",
|
||||
start_pat, middle_pat, end_pat, current
|
||||
);
|
||||
println!("Slice({}, Some({}), {}) = {};", start_pat, middle_pat, end_pat, current);
|
||||
self.current = middle_pat;
|
||||
self.visit_pat(middle);
|
||||
} else {
|
||||
println!("Slice(ref {}, None, ref {}) = {};", start_pat, end_pat, current);
|
||||
println!("Slice({}, None, {}) = {};", start_pat, end_pat, current);
|
||||
}
|
||||
|
||||
println!(" if {}.len() == {};", start_pat, start.len());
|
||||
|
@ -1042,11 +1024,11 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
// A local (let) binding:
|
||||
StmtKind::Local(local) => {
|
||||
let local_pat = self.next("local");
|
||||
println!("Local(ref {}) = {};", local_pat, current);
|
||||
println!("Local({}) = {};", local_pat, current);
|
||||
|
||||
if let Some(init) = local.init {
|
||||
let init_pat = self.next("init");
|
||||
println!(" if let Some(ref {}) = {}.init;", init_pat, local_pat);
|
||||
println!(" if let Some({}) = {}.init;", init_pat, local_pat);
|
||||
|
||||
self.current = init_pat;
|
||||
self.visit_expr(init);
|
||||
|
@ -1063,7 +1045,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
// Expr without trailing semi-colon (must have unit type):
|
||||
StmtKind::Expr(e) => {
|
||||
let e_pat = self.next("e");
|
||||
println!("Expr(ref {}, _) = {};", e_pat, current);
|
||||
println!("Expr({}, _) = {};", e_pat, current);
|
||||
|
||||
self.current = e_pat;
|
||||
self.visit_expr(e);
|
||||
|
@ -1072,7 +1054,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
|
|||
// Expr with trailing semi-colon (may have any type):
|
||||
StmtKind::Semi(e) => {
|
||||
let e_pat = self.next("e");
|
||||
println!("Semi(ref {}) = {};", e_pat, current);
|
||||
println!("Semi({}) = {};", e_pat, current);
|
||||
|
||||
self.current = e_pat;
|
||||
self.visit_expr(e);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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 StmtKind::Local(local) = stmt.kind;
|
||||
if let Some(init) = local.init;
|
||||
if let ExprKind::Cast(expr, cast_ty) = init.kind;
|
||||
if let TyKind::Path(ref qpath) = cast_ty.kind;
|
||||
if match_qpath(qpath, &["char"]);
|
||||
if let ExprKind::Lit(ref lit) = expr.kind;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
if_chain! {
|
||||
if let ExprKind::Block(ref block, ref label) = expr.kind;
|
||||
if let ExprKind::Block(block, label) = expr.kind;
|
||||
if block.stmts.len() == 3;
|
||||
if let StmtKind::Local(ref local) = block.stmts[0].kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let StmtKind::Local(local) = block.stmts[0].kind;
|
||||
if let Some(init) = local.init;
|
||||
if let ExprKind::Lit(ref lit) = init.kind;
|
||||
if let LitKind::Int(42, LitIntType::Signed(IntTy::I32)) = lit.node;
|
||||
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
|
||||
if name.as_str() == "x";
|
||||
if let StmtKind::Local(ref local1) = block.stmts[1].kind;
|
||||
if let Some(ref init1) = local1.init;
|
||||
if let StmtKind::Local(local1) = block.stmts[1].kind;
|
||||
if let Some(init1) = local1.init;
|
||||
if let ExprKind::Lit(ref lit1) = init1.kind;
|
||||
if let LitKind::Float(_, LitFloatType::Suffixed(FloatTy::F32)) = lit1.node;
|
||||
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local1.pat.kind;
|
||||
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 StmtKind::Semi(e) = block.stmts[2].kind;
|
||||
if let ExprKind::Unary(UnOp::Neg, inner) = e.kind;
|
||||
if let ExprKind::Path(ref qpath) = inner.kind;
|
||||
if match_qpath(qpath, &["x"]);
|
||||
if block.expr.is_none();
|
||||
|
@ -23,18 +23,18 @@ if_chain! {
|
|||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let ExprKind::Block(ref block, ref label) = expr.kind;
|
||||
if let ExprKind::Block(block, label) = expr.kind;
|
||||
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::Call(ref func, ref args) = init.kind;
|
||||
if let StmtKind::Local(local) = block.stmts[0].kind;
|
||||
if let Some(init) = local.init;
|
||||
if let ExprKind::Call(func, args) = init.kind;
|
||||
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 Some(trailing_expr) = block.expr;
|
||||
if let ExprKind::Call(func1, args1) = trailing_expr.kind;
|
||||
if let ExprKind::Path(ref qpath1) = func1.kind;
|
||||
if match_qpath(qpath1, &["drop"]);
|
||||
if args1.len() == 1;
|
||||
|
@ -45,17 +45,17 @@ if_chain! {
|
|||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let ExprKind::Closure(CaptureBy::Value, ref fn_decl, ref body_id, _, None) = expr.kind;
|
||||
if let ExprKind::Closure(CaptureBy::Value, fn_decl, body_id, _, None) = expr.kind;
|
||||
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::Call(func, args) = body.value.kind;
|
||||
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 ExprKind::Closure(CaptureBy::Value, fn_decl1, body_id1, _, Some(Movability::Static)) = args[0].kind;
|
||||
if let FnRetTy::DefaultReturn(_) = fn_decl1.output;
|
||||
let body1 = cx.tcx.hir().body(body_id1);
|
||||
if let ExprKind::Block(ref block, ref label) = body1.value.kind;
|
||||
if let ExprKind::Block(block, label) = body1.value.kind;
|
||||
if block.stmts.len() == 0;
|
||||
if block.expr.is_none();
|
||||
then {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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 StmtKind::Local(local) = stmt.kind;
|
||||
if let Some(init) = local.init;
|
||||
if let ExprKind::Call(func, args) = init.kind;
|
||||
if let ExprKind::Path(ref qpath) = func.kind;
|
||||
if match_qpath(qpath, &["{{root}}", "std", "cmp", "min"]);
|
||||
if args.len() == 2;
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
if_chain! {
|
||||
if let StmtKind::Local(ref local) = stmt.kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let StmtKind::Local(local) = stmt.kind;
|
||||
if let Some(init) = local.init;
|
||||
if let Some(higher::If { cond: cond, then: then, r#else: else_expr}) = higher::If::hir(init);
|
||||
if let ExprKind::Lit(ref lit) = cond.kind;
|
||||
if let LitKind::Bool(true) = lit.node;
|
||||
if let ExprKind::Block(ref block, ref label) = then.kind;
|
||||
if let ExprKind::Block(block, label) = then.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
|
||||
if let ExprKind::Binary(ref op, ref left, ref right) = e.kind;
|
||||
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
||||
if let ExprKind::Binary(op, left, right) = e.kind;
|
||||
if BinOpKind::Eq == op.node;
|
||||
if let ExprKind::Lit(ref lit1) = left.kind;
|
||||
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node;
|
||||
if let ExprKind::Lit(ref lit2) = right.kind;
|
||||
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit2.node;
|
||||
if block.expr.is_none();
|
||||
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
|
||||
if let ExprKind::Block(block1, label1) = else_expr.kind;
|
||||
if block1.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e1) = block1.stmts[0].kind;
|
||||
if let ExprKind::Binary(ref op1, ref left1, ref right1) = e1.kind;
|
||||
if let StmtKind::Semi(e1) = block1.stmts[0].kind;
|
||||
if let ExprKind::Binary(op1, left1, right1) = e1.kind;
|
||||
if BinOpKind::Eq == op1.node;
|
||||
if let ExprKind::Lit(ref lit3) = left1.kind;
|
||||
if let LitKind::Int(2, LitIntType::Unsuffixed) = lit3.node;
|
||||
|
@ -31,15 +31,15 @@ if_chain! {
|
|||
}
|
||||
if_chain! {
|
||||
if let Some(higher::IfLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then, if_else: else_expr}) = higher::IfLet::hir(expr);
|
||||
if let PatKind::Lit(ref lit_expr) = let_pat.kind;
|
||||
if let PatKind::Lit(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 qpath) = let_expr.kind;
|
||||
if match_qpath(qpath, &["a"]);
|
||||
if let ExprKind::Block(ref block, ref label) = if_then.kind;
|
||||
if let ExprKind::Block(block, label) = if_then.kind;
|
||||
if block.stmts.len() == 0;
|
||||
if block.expr.is_none();
|
||||
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
|
||||
if let ExprKind::Block(block1, label1) = else_expr.kind;
|
||||
if block1.stmts.len() == 0;
|
||||
if block1.expr.is_none();
|
||||
then {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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 StmtKind::Local(local) = stmt.kind;
|
||||
if let Some(init) = local.init;
|
||||
if let ExprKind::Call(func, args) = init.kind;
|
||||
if let ExprKind::Path(ref qpath) = func.kind;
|
||||
if match_qpath(qpath, &["std", "mem", "transmute"]);
|
||||
if args.len() == 1;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
if_chain! {
|
||||
if let ExprKind::DropTemps(ref expr) = expr.kind;
|
||||
if let ExprKind::DropTemps(expr) = expr.kind;
|
||||
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 qpath, ref fields, None) = arg.kind;
|
||||
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
|
||||
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
||||
if fields.len() == 2;
|
||||
if fields[0].ident.name.as_str() == "start";
|
||||
|
@ -12,10 +12,10 @@ if_chain! {
|
|||
if fields[1].ident.name.as_str() == "end";
|
||||
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
|
||||
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
||||
if let ExprKind::Block(ref block, ref label) = body.kind;
|
||||
if let ExprKind::Block(block, label) = body.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Local(ref local) = block.stmts[0].kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let StmtKind::Local(local) = block.stmts[0].kind;
|
||||
if let Some(init) = local.init;
|
||||
if let ExprKind::Path(ref qpath1) = init.kind;
|
||||
if match_qpath(qpath1, &["y"]);
|
||||
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
|
||||
|
@ -26,10 +26,10 @@ if_chain! {
|
|||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let ExprKind::DropTemps(ref expr) = expr.kind;
|
||||
if let ExprKind::DropTemps(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 qpath, ref fields, None) = arg.kind;
|
||||
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
|
||||
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
||||
if fields.len() == 2;
|
||||
if fields[0].ident.name.as_str() == "start";
|
||||
|
@ -38,20 +38,20 @@ if_chain! {
|
|||
if fields[1].ident.name.as_str() == "end";
|
||||
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
|
||||
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
||||
if let ExprKind::Block(ref block, ref label) = body.kind;
|
||||
if let ExprKind::Block(block, label) = body.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
|
||||
if let ExprKind::Break(ref destination, None) = e.kind;
|
||||
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
||||
if let ExprKind::Break(destination, None) = e.kind;
|
||||
if block.expr.is_none();
|
||||
then {
|
||||
// report your lint here
|
||||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let ExprKind::DropTemps(ref expr) = expr.kind;
|
||||
if let ExprKind::DropTemps(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 qpath, ref fields, None) = arg.kind;
|
||||
if let ExprKind::Struct(qpath, fields, None) = arg.kind;
|
||||
if matches!(qpath, QPath::LangItem(LangItem::Range, _));
|
||||
if fields.len() == 2;
|
||||
if fields[0].ident.name.as_str() == "start";
|
||||
|
@ -60,11 +60,11 @@ if_chain! {
|
|||
if fields[1].ident.name.as_str() == "end";
|
||||
if let ExprKind::Lit(ref lit1) = fields[1].expr.kind;
|
||||
if let LitKind::Int(10, LitIntType::Unsuffixed) = lit1.node;
|
||||
if let ExprKind::Block(ref block, ref label) = body.kind;
|
||||
if let ExprKind::Block(block, label) = body.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
|
||||
if let ExprKind::Break(ref destination, None) = e.kind;
|
||||
if let Some(ref label1) = destination.label;
|
||||
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
||||
if let ExprKind::Break(destination, None) = e.kind;
|
||||
if let Some(label1) = destination.label;
|
||||
if label_name.ident.name.as_str() == "'label";
|
||||
if block.expr.is_none();
|
||||
then {
|
||||
|
@ -75,10 +75,10 @@ if_chain! {
|
|||
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr);
|
||||
if let ExprKind::Path(ref qpath) = condition.kind;
|
||||
if match_qpath(qpath, &["a"]);
|
||||
if let ExprKind::Block(ref block, ref label) = body.kind;
|
||||
if let ExprKind::Block(block, label) = body.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
|
||||
if let ExprKind::Break(ref destination, None) = e.kind;
|
||||
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
||||
if let ExprKind::Break(destination, None) = e.kind;
|
||||
if block.expr.is_none();
|
||||
then {
|
||||
// report your lint here
|
||||
|
@ -86,25 +86,25 @@ if_chain! {
|
|||
}
|
||||
if_chain! {
|
||||
if let Some(higher::WhileLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then }) = higher::WhileLet::hir(expr);
|
||||
if let PatKind::Lit(ref lit_expr) = let_pat.kind;
|
||||
if let PatKind::Lit(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 qpath) = let_expr.kind;
|
||||
if match_qpath(qpath, &["a"]);
|
||||
if let ExprKind::Block(ref block, ref label) = if_then.kind;
|
||||
if let ExprKind::Block(block, label) = if_then.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
|
||||
if let ExprKind::Break(ref destination, None) = e.kind;
|
||||
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
||||
if let ExprKind::Break(destination, None) = e.kind;
|
||||
if block.expr.is_none();
|
||||
then {
|
||||
// report your lint here
|
||||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let ExprKind::Loop(ref body, ref label, LoopSource::Loop, _) = expr.kind;
|
||||
if let ExprKind::Loop(body, label, LoopSource::Loop, _) = expr.kind;
|
||||
if body.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref e) = body.stmts[0].kind;
|
||||
if let ExprKind::Break(ref destination, None) = e.kind;
|
||||
if let StmtKind::Semi(e) = body.stmts[0].kind;
|
||||
if let ExprKind::Break(destination, None) = e.kind;
|
||||
if body.expr.is_none();
|
||||
then {
|
||||
// report your lint here
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
if_chain! {
|
||||
if let StmtKind::Local(ref local) = stmt.kind;
|
||||
if let Some(ref init) = local.init;
|
||||
if let ExprKind::Match(ref scrutinee, ref arms, MatchSource::Normal) = init.kind;
|
||||
if let StmtKind::Local(local) = stmt.kind;
|
||||
if let Some(init) = local.init;
|
||||
if let ExprKind::Match(scrutinee, arms, MatchSource::Normal) = init.kind;
|
||||
if let ExprKind::Lit(ref lit) = scrutinee.kind;
|
||||
if let LitKind::Int(42, LitIntType::Unsuffixed) = lit.node;
|
||||
if arms.len() == 3;
|
||||
if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind;
|
||||
if let PatKind::Lit(lit_expr) = arms[0].pat.kind;
|
||||
if let ExprKind::Lit(ref lit1) = lit_expr.kind;
|
||||
if let LitKind::Int(16, LitIntType::Unsuffixed) = lit1.node;
|
||||
if let ExprKind::Lit(ref lit2) = arms[0].body.kind;
|
||||
if let LitKind::Int(5, LitIntType::Unsuffixed) = lit2.node;
|
||||
if let PatKind::Lit(ref lit_expr1) = arms[1].pat.kind;
|
||||
if let PatKind::Lit(lit_expr1) = arms[1].pat.kind;
|
||||
if let ExprKind::Lit(ref lit3) = lit_expr1.kind;
|
||||
if let LitKind::Int(17, LitIntType::Unsuffixed) = lit3.node;
|
||||
if let ExprKind::Block(ref block, ref label) = arms[1].body.kind;
|
||||
if let ExprKind::Block(block, label) = arms[1].body.kind;
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Local(ref local1) = block.stmts[0].kind;
|
||||
if let Some(ref init1) = local1.init;
|
||||
if let StmtKind::Local(local1) = block.stmts[0].kind;
|
||||
if let Some(init1) = local1.init;
|
||||
if let ExprKind::Lit(ref lit4) = init1.kind;
|
||||
if let LitKind::Int(3, LitIntType::Unsuffixed) = lit4.node;
|
||||
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 Some(trailing_expr) = block.expr;
|
||||
if let ExprKind::Path(ref qpath) = trailing_expr.kind;
|
||||
if match_qpath(qpath, &["x"]);
|
||||
if let PatKind::Wild = arms[2].pat.kind;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
if_chain! {
|
||||
if let ExprKind::Repeat(ref value, ref length) = expr.kind;
|
||||
if let ExprKind::Repeat(value, length) = expr.kind;
|
||||
if let ExprKind::Lit(ref lit) = value.kind;
|
||||
if let LitKind::Int(1, LitIntType::Unsigned(UintTy::U8)) = lit.node;
|
||||
if let ExprKind::Lit(ref lit1) = length.value.kind;
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
if_chain! {
|
||||
if let ExprKind::Struct(ref qpath, ref fields, None) = expr.kind;
|
||||
if let ExprKind::Struct(qpath, 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].expr);
|
||||
if let ExprKind::Lit(ref lit) = cond.kind;
|
||||
if let LitKind::Bool(true) = lit.node;
|
||||
if let ExprKind::Block(ref block, ref label) = then.kind;
|
||||
if let ExprKind::Block(block, label) = then.kind;
|
||||
if block.stmts.len() == 0;
|
||||
if let Some(trailing_expr) = &block.expr;
|
||||
if let Some(trailing_expr) = block.expr;
|
||||
if let ExprKind::Lit(ref lit1) = trailing_expr.kind;
|
||||
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node;
|
||||
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
|
||||
if let ExprKind::Block(block1, label1) = else_expr.kind;
|
||||
if block1.stmts.len() == 0;
|
||||
if let Some(trailing_expr1) = &block1.expr;
|
||||
if let Some(trailing_expr1) = block1.expr;
|
||||
if let ExprKind::Lit(ref lit2) = trailing_expr1.kind;
|
||||
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit2.node;
|
||||
then {
|
||||
|
@ -21,14 +21,14 @@ if_chain! {
|
|||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let PatKind::Struct(ref qpath, ref fields, false) = arm.kind;
|
||||
if let PatKind::Struct(ref qpath, 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;
|
||||
if let PatKind::Lit(lit_expr) = fields[0].kind;
|
||||
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
||||
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node;
|
||||
if let ExprKind::Block(ref block, ref label) = lit_expr.kind;
|
||||
if let ExprKind::Block(block, label) = lit_expr.kind;
|
||||
if block.stmts.len() == 0;
|
||||
if block.expr.is_none();
|
||||
then {
|
||||
|
@ -36,13 +36,13 @@ if_chain! {
|
|||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let PatKind::TupleStruct(ref qpath, ref fields, None) = arm.kind;
|
||||
if let PatKind::TupleStruct(ref qpath, 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 PatKind::Lit(lit_expr) = fields[0].kind;
|
||||
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
||||
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node;
|
||||
if let ExprKind::Block(ref block, ref label) = lit_expr.kind;
|
||||
if let ExprKind::Block(block, label) = lit_expr.kind;
|
||||
if block.stmts.len() == 0;
|
||||
if block.expr.is_none();
|
||||
then {
|
||||
|
@ -50,7 +50,7 @@ if_chain! {
|
|||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let ExprKind::MethodCall(ref method_name, ref args, _) = expr.kind;
|
||||
if let ExprKind::MethodCall(method_name, _, args, _) = expr.kind;
|
||||
if method_name.ident.name.as_str() == test;
|
||||
if args.len() == 1;
|
||||
if let ExprKind::Path(ref qpath) = args[0].kind;
|
||||
|
|
Loading…
Reference in a new issue