fn visit_expr(&mut self, expr: &'tcx Expr) {
if let ExprClosure(_, _, eid, _) = expr.node {
let body = self.cx.tcx.map.body(eid);
- let expr = &body.value;
- if matches!(expr.node, ExprBlock(_)) {
- self.found_block = Some(&expr);
+ let ex = &body.value;
+ if matches!(ex.node, ExprBlock(_)) {
+ self.found_block = Some(ex);
return;
}
}
fn check_closure(cx: &LateContext, expr: &Expr) {
if let ExprClosure(_, ref decl, eid, _) = expr.node {
let body = cx.tcx.map.body(eid);
- let ref ex = body.value;
+ let ex = &body.value;
if let ExprCall(ref caller, ref args) = ex.node {
if args.len() != decl.inputs.len() {
// Not the same number of arguments, there
// is no way the closure is the same as the function
return;
}
- if is_adjusted(cx, &ex) || args.iter().any(|arg| is_adjusted(cx, arg)) {
+ if is_adjusted(cx, ex) || args.iter().any(|arg| is_adjusted(cx, arg)) {
// Are the expression or the arguments type-adjusted? Then we need the closure
return;
}
}
}
- self.check_raw_ptr(cx, unsafety, decl, &body, nodeid);
+ self.check_raw_ptr(cx, unsafety, decl, body, nodeid);
}
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
if let hir::TraitMethod::Provided(eid) = *eid {
let body = cx.tcx.map.body(eid);
- self.check_raw_ptr(cx, sig.unsafety, &sig.decl, &body, item.id);
+ self.check_raw_ptr(cx, sig.unsafety, &sig.decl, body, item.id);
}
}
}
) {
let expr = &body.value;
if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(nodeid) {
- let raw_ptrs = iter_input_pats(&decl, body).zip(decl.inputs.iter())
- .filter_map(|(arg, ty)| raw_ptr_arg(arg, ty))
- .collect::<HashSet<_>>();
+ let raw_ptrs = iter_input_pats(decl, body).zip(decl.inputs.iter())
+ .filter_map(|(arg, ty)| raw_ptr_arg(arg, ty))
+ .collect::<HashSet<_>>();
if !raw_ptrs.is_empty() {
let mut v = DerefVisitor {
// extract lifetimes in input argument types
for arg in &func.inputs {
- input_visitor.visit_ty(&arg);
+ input_visitor.visit_ty(arg);
}
// extract lifetimes in output type
if let Return(ref ty) = func.output {
if in_external_macro(cx, body.value.span) {
return;
}
- check_fn(cx, decl, &body);
+ check_fn(cx, decl, body);
}
}
fn check_fn_decl(cx: &LateContext, decl: &FnDecl) {
for input in &decl.inputs {
- check_ty(cx, &input);
+ check_ty(cx, input);
}
if let FunctionRetTy::Return(ref ty) = decl.output {
impl<'a, 'tcx> TypeComplexityPass {
fn check_fndecl(&self, cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl) {
for arg in &decl.inputs {
- self.check_type(cx, &arg);
+ self.check_type(cx, arg);
}
if let Return(ref ty) = decl.output {
self.check_type(cx, ty);