Skip to content

Commit

Permalink
remove manual fn_decl extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Akida31 committed Oct 11, 2022
1 parent 121b431 commit 0f5409b
Showing 1 changed file with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3065,23 +3065,9 @@ fn hint_missing_borrow<'tcx>(
}
};

let fn_decl = match found_node {
Node::Expr(expr) => match &expr.kind {
hir::ExprKind::Closure(hir::Closure { fn_decl, .. }) => fn_decl,
kind => {
span_bug!(found_span, "expression must be a closure but is {:?}", kind)
}
},
Node::Item(item) => match &item.kind {
hir::ItemKind::Fn(signature, _generics, _body) => signature.decl,
kind => {
span_bug!(found_span, "item must be a function but is {:?}", kind)
}
},
node => {
span_bug!(found_span, "node must be a expr or item but is {:?}", node)
}
};
let fn_decl = found_node
.fn_decl()
.unwrap_or_else(|| span_bug!(found_span, "found node must be a function"));

let arg_spans = fn_decl.inputs.iter().map(|ty| ty.span);

Expand Down

0 comments on commit 0f5409b

Please sign in to comment.