rust-clippy/tests/ui/author/blocks.stdout

65 lines
2.6 KiB
Text
Raw Normal View History

2019-05-19 14:52:44 +00:00
if_chain! {
2021-11-05 22:05:04 +00:00
if let ExprKind::Block(block, None) = expr.kind;
2021-10-29 01:39:41 +00:00
if block.stmts.len() == 3;
2021-11-10 21:59:49 +00:00
if let StmtKind::Local(local) = block.stmts[0].kind;
if let Some(init) = local.init;
2021-07-23 21:02:09 +00:00
if let ExprKind::Lit(ref lit) = init.kind;
2021-10-29 01:39:41 +00:00
if let LitKind::Int(42, LitIntType::Signed(IntTy::I32)) = lit.node;
2021-07-23 21:02:09 +00:00
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
if name.as_str() == "x";
2021-11-10 21:59:49 +00:00
if let StmtKind::Local(local1) = block.stmts[1].kind;
if let Some(init1) = local1.init;
2021-10-29 01:39:41 +00:00
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";
2021-11-10 21:59:49 +00:00
if let StmtKind::Semi(e) = block.stmts[2].kind;
if let ExprKind::Unary(UnOp::Neg, inner) = e.kind;
2021-11-08 23:05:37 +00:00
if let ExprKind::Path(ref qpath) = inner.kind;
if match_qpath(qpath, &["x"]);
2021-07-25 21:35:35 +00:00
if block.expr.is_none();
2019-05-19 14:52:44 +00:00
then {
// report your lint here
}
}
if_chain! {
2021-11-05 22:05:04 +00:00
if let ExprKind::Block(block, None) = expr.kind;
2021-07-23 21:02:09 +00:00
if block.stmts.len() == 1;
2021-11-10 21:59:49 +00:00
if let StmtKind::Local(local) = block.stmts[0].kind;
if let Some(init) = local.init;
if let ExprKind::Call(func, args) = init.kind;
2021-11-08 23:05:37 +00:00
if let ExprKind::Path(ref qpath) = func.kind;
if match_qpath(qpath, &["String", "new"]);
2021-11-05 22:05:04 +00:00
if args.is_empty();
2021-07-23 21:02:09 +00:00
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
if name.as_str() == "expr";
2021-11-10 21:59:49 +00:00
if let Some(trailing_expr) = block.expr;
if let ExprKind::Call(func1, args1) = trailing_expr.kind;
2021-11-08 23:05:37 +00:00
if let ExprKind::Path(ref qpath1) = func1.kind;
if match_qpath(qpath1, &["drop"]);
2021-07-23 21:02:09 +00:00
if args1.len() == 1;
2021-11-08 23:05:37 +00:00
if let ExprKind::Path(ref qpath2) = args1[0].kind;
if match_qpath(qpath2, &["expr"]);
2019-05-19 14:52:44 +00:00
then {
// report your lint here
}
}
2021-10-29 01:39:41 +00:00
if_chain! {
2021-11-10 21:59:49 +00:00
if let ExprKind::Closure(CaptureBy::Value, fn_decl, body_id, _, None) = expr.kind;
2021-11-10 21:42:49 +00:00
if let FnRetTy::DefaultReturn(_) = fn_decl.output;
2021-11-05 22:05:04 +00:00
let expr1 = &cx.tcx.hir().body(body_id).value;
if let ExprKind::Call(func, args) = expr1.kind;
2021-11-08 23:05:37 +00:00
if let ExprKind::Path(ref qpath) = func.kind;
if matches!(qpath, QPath::LangItem(LangItem::FromGenerator, _));
2021-10-29 01:39:41 +00:00
if args.len() == 1;
2021-11-10 21:59:49 +00:00
if let ExprKind::Closure(CaptureBy::Value, fn_decl1, body_id1, _, Some(Movability::Static)) = args[0].kind;
2021-11-10 21:42:49 +00:00
if let FnRetTy::DefaultReturn(_) = fn_decl1.output;
2021-11-05 22:05:04 +00:00
let expr2 = &cx.tcx.hir().body(body_id1).value;
if let ExprKind::Block(block, None) = expr2.kind;
if block.stmts.is_empty();
2021-10-29 01:39:41 +00:00
if block.expr.is_none();
then {
// report your lint here
}
}