author: fix some bugs

This commit is contained in:
Cameron Steffen 2021-11-10 15:42:49 -06:00
parent ce01346ac1
commit d0cc201204
6 changed files with 59 additions and 59 deletions

View File

@ -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(ref {}) = {};", label_bind, self.current);
let label_name_bind = self.next("label_name");
let label_name = label.ident.name;
@ -246,7 +246,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
let str_pat = self.next("s");
println!(" if let LitKind::Str(ref {}, _) = {}.node;", str_pat, lit_pat);
println!(" if {}.as_str() == {:?}", str_pat, &*text.as_str());
println!(" if {}.as_str() == {:?};", str_pat, &*text.as_str());
},
}
}
@ -311,7 +311,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
let body_pat = self.next("body");
println!(
" if let Some(higher::While {{ condition: {}, body: {} }}) = higher::While::hir({})",
" if let Some(higher::While {{ condition: {}, body: {} }}) = higher::While::hir({});",
condition_pat, body_pat, self.current
);
@ -335,7 +335,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
let if_then_pat = self.next("if_then");
println!(
" if let Some(higher::WhileLet {{ let_pat: {}, let_expr: {}, if_then: {} }}) = higher::WhileLet::hir({})",
" if let Some(higher::WhileLet {{ let_pat: {}, let_expr: {}, if_then: {} }}) = higher::WhileLet::hir({});",
let_pat_, let_expr_pat, if_then_pat, self.current
);
@ -364,7 +364,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
let else_pat = self.next("else_expr");
println!(
" if let Some(higher::IfLet {{ let_pat: {}, let_expr: {}, if_then: {}, if_else: {}}}) = higher::IfLet::hir({})",
" if let Some(higher::IfLet {{ let_pat: {}, let_expr: {}, if_then: {}, if_else: {}}}) = higher::IfLet::hir({});",
let_pat_, let_expr_pat, if_then_pat, else_pat, self.current
);
@ -391,7 +391,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
let else_pat = self.next("else_expr");
println!(
" if let Some(higher::If {{ cond: {}, then: {}, r#else: {}}}) = higher::If::hir({})",
" if let Some(higher::If {{ cond: {}, then: {}, r#else: {}}}) = higher::If::hir({});",
cond_pat, then_pat, else_pat, self.current
);
@ -415,7 +415,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
let body_pat = self.next("body");
println!(
" if let Some(higher::ForLoop {{ pat: {}, arg: {}, body: {}, ..}}) = higher::ForLoop::hir({})",
" if let Some(higher::ForLoop {{ pat: {}, arg: {}, body: {}, ..}}) = higher::ForLoop::hir({});",
pat_, arg_pat, body_pat, self.current
);
@ -596,7 +596,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
let label_pat = self.next("label");
println!(
"Loop(ref {}, ref {}, LoopSource::{:?}) = {};",
"Loop(ref {}, ref {}, LoopSource::{:?}, _) = {};",
body_pat, label_pat, des, current
);
@ -626,10 +626,10 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
let body_id_pat = self.next("body_id");
println!(
"Closure({}, ref {}, ref {}, _, {}) = {}",
"Closure({}, ref {}, ref {}, _, {}) = {};",
capture_by, fn_decl_pat, body_id_pat, movability, current
);
println!(" if let {} = {}.output", ret_ty, fn_decl_pat);
println!(" if let {} = {}.output;", ret_ty, fn_decl_pat);
let hir = self.cx.tcx.hir();
let body = hir.body(body_id);
@ -699,7 +699,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
let field_name_pat = self.next("field_name");
println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current);
println!(" if {}.as_str() == {:?}", field_name_pat, field_ident.as_str());
println!(" if {}.as_str() == {:?};", field_name_pat, field_ident.as_str());
self.current = obj_pat;
self.visit_expr(object);
@ -804,13 +804,13 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
for (i, field) in fields.iter().enumerate() {
println!(
" if {}[{}].ident.name.as_str() == {:?}",
" if {}[{}].ident.name.as_str() == {:?};",
fields_pat,
i,
&*field.ident.name.as_str()
);
self.current = format!("{}[{}]", fields_pat, i);
self.current = format!("{}[{}].expr", fields_pat, i);
self.visit_expr(field.expr);
}
},
@ -909,7 +909,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
for (i, field) in fields.iter().enumerate() {
println!(
" if {}[{}].ident.name.as_str() == {:?}",
" if {}[{}].ident.name.as_str() == {:?};",
fields_pat,
i,
&*field.ident.name.as_str()
@ -981,7 +981,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrintVisitor<'a, '_> {
},
PatKind::Lit(lit_expr) => {
let lit_expr_pat = self.next("lit_expr");
println!("Lit(ref {}) = {}", lit_expr_pat, current);
println!("Lit(ref {}) = {};", lit_expr_pat, current);
self.current = lit_expr_pat;
self.visit_expr(lit_expr);
@ -1063,7 +1063,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(ref {}, _) = {};", e_pat, current);
self.current = e_pat;
self.visit_expr(e);
@ -1072,7 +1072,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(ref {}) = {};", e_pat, current);
self.current = e_pat;
self.visit_expr(e);

View File

@ -13,7 +13,7 @@ if_chain! {
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 StmtKind::Semi(ref e) = block.stmts[2].kind;
if let ExprKind::Unary(UnOp::Neg, ref inner) = e.kind;
if let ExprKind::Path(ref qpath) = inner.kind;
if match_qpath(qpath, &["x"]);
@ -45,15 +45,15 @@ if_chain! {
}
}
if_chain! {
if let ExprKind::Closure(CaptureBy::Value, ref fn_decl, ref body_id, _, None) = expr.kind
if let FnRetTy::DefaultReturn(_) = fn_decl.output
if let ExprKind::Closure(CaptureBy::Value, ref fn_decl, ref 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::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
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;
let body1 = cx.tcx.hir().body(body_id1);
if let ExprKind::Block(ref block, ref label) = body1.value.kind;
if block.stmts.len() == 0;

View File

@ -1,12 +1,12 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.kind;
if let Some(ref init) = local.init;
if let Some(higher::If { cond: cond, then: then, r#else: else_expr}) = higher::If::hir(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 block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
if let ExprKind::Binary(ref op, ref left, ref right) = e.kind;
if BinOpKind::Eq == op.node;
if let ExprKind::Lit(ref lit1) = left.kind;
@ -16,7 +16,7 @@ if_chain! {
if block.expr.is_none();
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
if block1.stmts.len() == 1;
if let StmtKind::Semi(ref e1, _) = block1.stmts[0].kind
if let StmtKind::Semi(ref e1) = block1.stmts[0].kind;
if let ExprKind::Binary(ref op1, ref left1, ref right1) = e1.kind;
if BinOpKind::Eq == op1.node;
if let ExprKind::Lit(ref lit3) = left1.kind;
@ -30,8 +30,8 @@ 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 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 ExprKind::Lit(ref lit) = lit_expr.kind;
if let LitKind::Bool(true) = lit.node;
if let ExprKind::Path(ref qpath) = let_expr.kind;

View File

@ -1,16 +1,16 @@
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 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 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;
if fields[0].ident.name.as_str() == "start";
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
if fields[1].ident.name.as_str() == "end"
if let ExprKind::Lit(ref lit1) = fields[1].kind;
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 block.stmts.len() == 1;
@ -27,20 +27,20 @@ if_chain! {
}
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 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 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;
if fields[0].ident.name.as_str() == "start";
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
if fields[1].ident.name.as_str() == "end"
if let ExprKind::Lit(ref lit1) = fields[1].kind;
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 block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
if let ExprKind::Break(ref destination, None) = e.kind;
if block.expr.is_none();
then {
@ -49,22 +49,22 @@ if_chain! {
}
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 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 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;
if fields[0].ident.name.as_str() == "start";
if let ExprKind::Lit(ref lit) = fields[0].expr.kind;
if let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node;
if fields[1].ident.name.as_str() == "end"
if let ExprKind::Lit(ref lit1) = fields[1].kind;
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 block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
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 Some(ref label1) = destination.label;
if label_name.ident.name.as_str() == "'label";
if block.expr.is_none();
then {
@ -72,12 +72,12 @@ if_chain! {
}
}
if_chain! {
if let Some(higher::While { condition: condition, body: body }) = higher::While::hir(expr)
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 block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
if let ExprKind::Break(ref destination, None) = e.kind;
if block.expr.is_none();
then {
@ -85,15 +85,15 @@ 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 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 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 block.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
if let StmtKind::Semi(ref e) = block.stmts[0].kind;
if let ExprKind::Break(ref destination, None) = e.kind;
if block.expr.is_none();
then {
@ -101,9 +101,9 @@ if_chain! {
}
}
if_chain! {
if let ExprKind::Loop(ref body, ref label, LoopSource::Loop) = expr.kind;
if let ExprKind::Loop(ref body, ref label, LoopSource::Loop, _) = expr.kind;
if body.stmts.len() == 1;
if let StmtKind::Semi(ref e, _) = body.stmts[0].kind
if let StmtKind::Semi(ref e) = body.stmts[0].kind;
if let ExprKind::Break(ref destination, None) = e.kind;
if body.expr.is_none();
then {

View File

@ -7,7 +7,7 @@ if_chain! {
if arms.len() == 3;
if let ExprKind::Lit(ref lit1) = arms[0].body.kind;
if let LitKind::Int(5, LitIntType::Unsuffixed) = lit1.node;
if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind
if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind;
if let ExprKind::Lit(ref lit2) = lit_expr.kind;
if let LitKind::Int(16, LitIntType::Unsuffixed) = lit2.node;
if let ExprKind::Block(ref block, ref label) = arms[1].body.kind;
@ -21,7 +21,7 @@ if_chain! {
if let Some(trailing_expr) = &block.expr;
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 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;
if let ExprKind::Lit(ref lit5) = arms[2].body.kind;

View File

@ -2,8 +2,8 @@ if_chain! {
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])
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;
@ -24,8 +24,8 @@ if_chain! {
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
if fields[0].ident.name.as_str() == "field";
if let PatKind::Lit(ref 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;
@ -39,7 +39,7 @@ if_chain! {
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 PatKind::Lit(ref 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;