Skip to content

Commit d2a781a

Browse files
committed
Remove unwrap()s
1 parent 87d323c commit d2a781a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1521,12 +1521,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
15211521
let fn_kind = self_ty.prefix_string(self.tcx);
15221522
let (span, closure_span) = if let ty::Closure(def_id, _) = self_ty.kind() {
15231523
let def_span = self.tcx.def_span(def_id);
1524-
let node = self.tcx.hir_node_by_def_id(def_id.as_local().unwrap());
1525-
if let Some(fn_decl) = node.fn_decl() {
1524+
if let Some(local_def_id) = def_id.as_local()
1525+
&& let node = self.tcx.hir_node_by_def_id(local_def_id)
1526+
&& let Some(fn_decl) = node.fn_decl()
1527+
&& let Some(id) = node.body_id()
1528+
{
15261529
span = match fn_decl.output {
15271530
hir::FnRetTy::Return(ty) => ty.span,
15281531
hir::FnRetTy::DefaultReturn(_) => {
1529-
let body = self.tcx.hir().body(node.body_id().unwrap());
1532+
let body = self.tcx.hir().body(id);
15301533
match body.value.kind {
15311534
hir::ExprKind::Block(
15321535
hir::Block { expr: Some(expr), .. },

0 commit comments

Comments
 (0)