Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ad6e250

Browse files
committed
Use Result combinators instead of manual matching
1 parent 13a29b8 commit ad6e250

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
@@ -334,13 +334,11 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
334334

335335
let alloc_id = mplace.ptr().provenance.unwrap();
336336

337-
// Validation failed, report an error.
338-
if let Err(error) = validation {
339-
Err(ecx.const_report_error(error, alloc_id))
340-
} else {
337+
validation
338+
// Validation failed, report an error.
339+
.map_err(|error| ecx.const_report_error(error, alloc_id))
341340
// Convert to raw constant
342-
Ok(ConstAlloc { alloc_id, ty: mplace.layout.ty })
343-
}
341+
.map(|()| ConstAlloc { alloc_id, ty: mplace.layout.ty })
344342
}
345343
}
346344
}

0 commit comments

Comments
 (0)