Skip to content

Commit d8bd11a

Browse files
committed
Use Result combinators instead of manual matching
1 parent a7fefc7 commit d8bd11a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,11 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
336336

337337
let alloc_id = mplace.ptr().provenance.unwrap();
338338

339-
// Validation failed, report an error.
340-
if let Err(error) = validation {
341-
Err(const_report_error(&ecx, error, alloc_id))
342-
} else {
339+
validation
340+
// Validation failed, report an error.
341+
.map_err(|error| const_report_error(&ecx, error, alloc_id))
343342
// Convert to raw constant
344-
Ok(ConstAlloc { alloc_id, ty: mplace.layout.ty })
345-
}
343+
.map(|()| ConstAlloc { alloc_id, ty: mplace.layout.ty })
346344
}
347345
}
348346
}

0 commit comments

Comments
 (0)