impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
let expr = match s.node {
- hir::StmtSemi(ref expr, _) => &**expr,
+ hir::StmtKind::Semi(ref expr, _) => &**expr,
_ => return,
};
- if let hir::ExprRet(..) = expr.node {
+ if let hir::ExprKind::Ret(..) = expr.node {
return;
}
let mut fn_warned = false;
let mut op_warned = false;
let maybe_def = match expr.node {
- hir::ExprCall(ref callee, _) => {
+ hir::ExprKind::Call(ref callee, _) => {
match callee.node {
- hir::ExprPath(ref qpath) => {
+ hir::ExprKind::Path(ref qpath) => {
let def = cx.tables.qpath_def(qpath, callee.hir_id);
if let Def::Fn(_) = def {
Some(def)
_ => None
}
},
- hir::ExprMethodCall(..) => {
+ hir::ExprKind::MethodCall(..) => {
cx.tables.type_dependent_defs().get(expr.hir_id).cloned()
},
_ => None
// Hardcoding operators here seemed more expedient than the
// refactoring that would be needed to look up the `#[must_use]`
// attribute which does exist on the comparison trait methods
- hir::ExprBinary(bin_op, ..) => {
+ hir::ExprKind::Binary(bin_op, ..) => {
match bin_op.node {
- hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => {
+ hir::BinOpKind::Eq |
+ hir::BinOpKind::Lt |
+ hir::BinOpKind::Le |
+ hir::BinOpKind::Ne |
+ hir::BinOpKind::Ge |
+ hir::BinOpKind::Gt => {
Some("comparison")
},
- hir::BiAdd | hir::BiSub | hir::BiDiv | hir::BiMul | hir::BiRem => {
+ hir::BinOpKind::Add |
+ hir::BinOpKind::Sub |
+ hir::BinOpKind::Div |
+ hir::BinOpKind::Mul |
+ hir::BinOpKind::Rem => {
Some("arithmetic operation")
},
- hir::BiAnd | hir::BiOr => {
+ hir::BinOpKind::And | hir::BinOpKind::Or => {
Some("logical operation")
},
- hir::BiBitXor | hir::BiBitAnd | hir::BiBitOr | hir::BiShl | hir::BiShr => {
+ hir::BinOpKind::BitXor |
+ hir::BinOpKind::BitAnd |
+ hir::BinOpKind::BitOr |
+ hir::BinOpKind::Shl |
+ hir::BinOpKind::Shr => {
Some("bitwise operation")
},
}
},
- hir::ExprUnary(..) => Some("unary operation"),
+ hir::ExprKind::Unary(..) => Some("unary operation"),
_ => None
};
fn check_must_use(cx: &LateContext, def_id: DefId, sp: Span, describe_path: &str) -> bool {
for attr in cx.tcx.get_attrs(def_id).iter() {
if attr.check_name("must_use") {
- let mut msg = format!("unused {}`{}` which must be used",
+ let msg = format!("unused {}`{}` which must be used",
describe_path, cx.tcx.item_path_str(def_id));
let mut err = cx.struct_span_lint(UNUSED_MUST_USE, sp, &msg);
// check for #[must_use = "..."]
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
- if let hir::StmtSemi(ref expr, _) = s.node {
- if let hir::ExprPath(_) = expr.node {
+ if let hir::StmtKind::Semi(ref expr, _) = s.node {
+ if let hir::ExprKind::Path(_) = expr.node {
cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect");
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
match e.node {
- hir::ExprBox(_) => {}
+ hir::ExprKind::Box(_) => {}
_ => return,
}