StmtKind
This commit is contained in:
parent
12ded030b6
commit
8cf463fe93
23 changed files with 66 additions and 66 deletions
|
|
@ -592,9 +592,9 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
|
|||
let current = format!("{}.node", self.current);
|
||||
match s.node {
|
||||
// Could be an item or a local (let) binding:
|
||||
StmtDecl(ref decl, _) => {
|
||||
StmtKind::Decl(ref decl, _) => {
|
||||
let decl_pat = self.next("decl");
|
||||
println!("StmtDecl(ref {}, _) = {}", decl_pat, current);
|
||||
println!("StmtKind::Decl(ref {}, _) = {}", decl_pat, current);
|
||||
print!(" if let Decl_::");
|
||||
let current = format!("{}.node", decl_pat);
|
||||
match decl.node {
|
||||
|
|
@ -619,17 +619,17 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
|
|||
}
|
||||
|
||||
// Expr without trailing semi-colon (must have unit type):
|
||||
StmtExpr(ref e, _) => {
|
||||
StmtKind::Expr(ref e, _) => {
|
||||
let e_pat = self.next("e");
|
||||
println!("StmtExpr(ref {}, _) = {}", e_pat, current);
|
||||
println!("StmtKind::Expr(ref {}, _) = {}", e_pat, current);
|
||||
self.current = e_pat;
|
||||
self.visit_expr(e);
|
||||
},
|
||||
|
||||
// Expr with trailing semi-colon (may have any type):
|
||||
StmtSemi(ref e, _) => {
|
||||
StmtKind::Semi(ref e, _) => {
|
||||
let e_pat = self.next("e");
|
||||
println!("StmtSemi(ref {}, _) = {}", e_pat, current);
|
||||
println!("StmtKind::Semi(ref {}, _) = {}", e_pat, current);
|
||||
self.current = e_pat;
|
||||
self.visit_expr(e);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -191,9 +191,9 @@ pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)>
|
|||
if let hir::ExprKind::Loop(ref block, _, _) = arms[0].body.node;
|
||||
if block.expr.is_none();
|
||||
if let [ _, _, ref let_stmt, ref body ] = *block.stmts;
|
||||
if let hir::StmtDecl(ref decl, _) = let_stmt.node;
|
||||
if let hir::StmtKind::Decl(ref decl, _) = let_stmt.node;
|
||||
if let hir::DeclLocal(ref decl) = decl.node;
|
||||
if let hir::StmtExpr(ref expr, _) = body.node;
|
||||
if let hir::StmtKind::Expr(ref expr, _) = body.node;
|
||||
then {
|
||||
return Some((&*decl.pat, &iterargs[0], expr));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
|||
/// Check whether two statements are the same.
|
||||
pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool {
|
||||
match (&left.node, &right.node) {
|
||||
(&StmtDecl(ref l, _), &StmtDecl(ref r, _)) => {
|
||||
(&StmtKind::Decl(ref l, _), &StmtKind::Decl(ref r, _)) => {
|
||||
if let (&DeclLocal(ref l), &DeclLocal(ref r)) = (&l.node, &r.node) {
|
||||
both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r)) && both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
},
|
||||
(&StmtExpr(ref l, _), &StmtExpr(ref r, _)) | (&StmtSemi(ref l, _), &StmtSemi(ref r, _)) => {
|
||||
(&StmtKind::Expr(ref l, _), &StmtKind::Expr(ref r, _)) | (&StmtKind::Semi(ref l, _), &StmtKind::Semi(ref r, _)) => {
|
||||
self.eq_expr(l, r)
|
||||
},
|
||||
_ => false,
|
||||
|
|
@ -613,8 +613,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
|||
|
||||
pub fn hash_stmt(&mut self, b: &Stmt) {
|
||||
match b.node {
|
||||
StmtDecl(ref decl, _) => {
|
||||
let c: fn(_, _) -> _ = StmtDecl;
|
||||
StmtKind::Decl(ref decl, _) => {
|
||||
let c: fn(_, _) -> _ = StmtKind::Decl;
|
||||
c.hash(&mut self.s);
|
||||
|
||||
if let DeclLocal(ref local) = decl.node {
|
||||
|
|
@ -623,13 +623,13 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
},
|
||||
StmtExpr(ref expr, _) => {
|
||||
let c: fn(_, _) -> _ = StmtExpr;
|
||||
StmtKind::Expr(ref expr, _) => {
|
||||
let c: fn(_, _) -> _ = StmtKind::Expr;
|
||||
c.hash(&mut self.s);
|
||||
self.hash_expr(expr);
|
||||
},
|
||||
StmtSemi(ref expr, _) => {
|
||||
let c: fn(_, _) -> _ = StmtSemi;
|
||||
StmtKind::Semi(ref expr, _) => {
|
||||
let c: fn(_, _) -> _ = StmtKind::Semi;
|
||||
c.hash(&mut self.s);
|
||||
self.hash_expr(expr);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
return;
|
||||
}
|
||||
match stmt.node {
|
||||
hir::StmtDecl(ref decl, _) => print_decl(cx, decl),
|
||||
hir::StmtExpr(ref e, _) | hir::StmtSemi(ref e, _) => print_expr(cx, e, 0),
|
||||
hir::StmtKind::Decl(ref decl, _) => print_decl(cx, decl),
|
||||
hir::StmtKind::Expr(ref e, _) | hir::StmtKind::Semi(ref e, _) => print_expr(cx, e, 0),
|
||||
}
|
||||
}
|
||||
// fn check_foreign_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue