Make it compile again
This commit is contained in:
@@ -56,8 +56,8 @@ fn is_nil_type(ty: ty::Ty) -> bool {
|
|||||||
fn is_nil_function(cx: &LateContext, expr: &hir::Expr) -> bool {
|
fn is_nil_function(cx: &LateContext, expr: &hir::Expr) -> bool {
|
||||||
let ty = cx.tables.expr_ty(expr);
|
let ty = cx.tables.expr_ty(expr);
|
||||||
|
|
||||||
if let ty::TyFnDef(_, _, bare) = ty.sty {
|
if let ty::TyFnDef(id, _) = ty.sty {
|
||||||
if let Some(fn_type) = cx.tcx.no_late_bound_regions(&bare.sig) {
|
if let Some(fn_type) = cx.tcx.fn_sig(id).no_late_bound_regions() {
|
||||||
return is_nil_type(fn_type.output());
|
return is_nil_type(fn_type.output());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,17 +115,18 @@ fn reduce_nil_expression<'a>(cx: &LateContext, expr: &'a hir::Expr) -> Option<Sp
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn nil_closure<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'a hir::Expr) -> Option<(&'tcx hir::Arg, &'a hir::Expr)> {
|
fn nil_closure<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'a hir::Expr) -> Option<(&'tcx hir::Arg, &'a hir::Expr)> {
|
||||||
if let hir::ExprClosure(_, ref decl, inner_expr_id, _) = expr.node {
|
if let hir::ExprClosure(_, ref decl, inner_expr_id, _, _) = expr.node {
|
||||||
let body = cx.tcx.map.body(inner_expr_id);
|
let body = cx.tcx.hir.body(inner_expr_id);
|
||||||
let body_expr = &body.value;
|
let body_expr = &body.value;
|
||||||
|
|
||||||
if_let_chain! {[
|
if_chain! {
|
||||||
decl.inputs.len() == 1,
|
if decl.inputs.len() == 1;
|
||||||
is_nil_expression(cx, body_expr),
|
if is_nil_expression(cx, body_expr);
|
||||||
let Some(binding) = iter_input_pats(&decl, body).next(),
|
if let Some(binding) = iter_input_pats(&decl, body).next();
|
||||||
], {
|
then {
|
||||||
return Some((binding, body_expr))
|
return Some((binding, body_expr));
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@@ -172,7 +173,7 @@ fn lint_map_nil_fn(cx: &LateContext, stmt: &hir::Stmt, expr: &hir::Expr, map_arg
|
|||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
fn check_stmt(&mut self, cx: &LateContext, stmt: &hir::Stmt) {
|
fn check_stmt(&mut self, cx: &LateContext, stmt: &hir::Stmt) {
|
||||||
if in_macro(cx, stmt.span) {
|
if in_macro(stmt.span) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user