Skip to content

Commit f43a874

Browse files
committed
Remove unwrap()s
1 parent a518f5e commit f43a874

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -1505,12 +1505,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
15051505
let fn_kind = self_ty.prefix_string(self.tcx);
15061506
let (span, closure_span) = if let ty::Closure(def_id, _) = self_ty.kind() {
15071507
let def_span = self.tcx.def_span(def_id);
1508-
let node = self.tcx.hir_node_by_def_id(def_id.as_local().unwrap());
1509-
if let Some(fn_decl) = node.fn_decl() {
1508+
if let Some(local_def_id) = def_id.as_local()
1509+
&& let node = self.tcx.hir_node_by_def_id(local_def_id)
1510+
&& let Some(fn_decl) = node.fn_decl()
1511+
&& let Some(id) = node.body_id()
1512+
{
15101513
span = match fn_decl.output {
15111514
hir::FnRetTy::Return(ty) => ty.span,
15121515
hir::FnRetTy::DefaultReturn(_) => {
1513-
let body = self.tcx.hir().body(node.body_id().unwrap());
1516+
let body = self.tcx.hir().body(id);
15141517
match body.value.kind {
15151518
hir::ExprKind::Block(
15161519
hir::Block { expr: Some(expr), .. },

0 commit comments

Comments
 (0)