diff options
| author | akida31 <akida3@protonmail.com> | 2022-10-11 17:48:46 +0200 |
|---|---|---|
| committer | akida31 <akida3@protonmail.com> | 2022-12-13 16:29:13 +0100 |
| commit | 4d87fb5d1125b5bceb83b34eb68bc0e73fcf636a (patch) | |
| tree | cc0c2a1a4a65b073093a0a7ce36f9a71f10d3e08 | |
| parent | 7822822d51ecde145747c19a8cf57444666e9a3b (diff) | |
| download | rust-4d87fb5d1125b5bceb83b34eb68bc0e73fcf636a.tar.gz rust-4d87fb5d1125b5bceb83b34eb68bc0e73fcf636a.zip | |
remove manual `fn_decl` extraction
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index f20cecdb74f..17206b21af0 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -3412,23 +3412,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); |
