Skip to content

Commit 0f5409b

Browse files
committed
remove manual fn_decl extraction
1 parent 121b431 commit 0f5409b

File tree

1 file changed

+3
-17
lines changed
  • compiler/rustc_trait_selection/src/traits/error_reporting

1 file changed

+3
-17
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,23 +3065,9 @@ fn hint_missing_borrow<'tcx>(
30653065
}
30663066
};
30673067

3068-
let fn_decl = match found_node {
3069-
Node::Expr(expr) => match &expr.kind {
3070-
hir::ExprKind::Closure(hir::Closure { fn_decl, .. }) => fn_decl,
3071-
kind => {
3072-
span_bug!(found_span, "expression must be a closure but is {:?}", kind)
3073-
}
3074-
},
3075-
Node::Item(item) => match &item.kind {
3076-
hir::ItemKind::Fn(signature, _generics, _body) => signature.decl,
3077-
kind => {
3078-
span_bug!(found_span, "item must be a function but is {:?}", kind)
3079-
}
3080-
},
3081-
node => {
3082-
span_bug!(found_span, "node must be a expr or item but is {:?}", node)
3083-
}
3084-
};
3068+
let fn_decl = found_node
3069+
.fn_decl()
3070+
.unwrap_or_else(|| span_bug!(found_span, "found node must be a function"));
30853071

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

0 commit comments

Comments
 (0)