Skip to content

Commit 2269109

Browse files
authored
Merge pull request #749 from nicholasbishop/bishop-error-from-status
uefi: Panic if an error is created from Status::SUCCESS
2 parents 4db6d17 + 1a9974f commit 2269109

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
available regardless of whether the `global_allocator` feature is enabled. The
99
`global_allocator` feature now only controls whether `allocator::Allocator` is
1010
set as Rust's global allocator.
11+
- `Error::new` and `Error::from` now panic if the status is `SUCCESS`.
1112

1213
## uefi-macros - [Unreleased]
1314

uefi/src/result/error.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ pub struct Error<Data: Debug = ()> {
1414

1515
impl<Data: Debug> Error<Data> {
1616
/// Create an `Error`.
17+
///
18+
/// # Panics
19+
///
20+
/// Panics if `status` is [`Status::SUCCESS`].
1721
pub const fn new(status: Status, data: Data) -> Self {
22+
assert!(!matches!(status, Status::SUCCESS));
1823
Self { status, data }
1924
}
2025

@@ -39,7 +44,7 @@ impl<Data: Debug> Error<Data> {
3944

4045
impl From<Status> for Error<()> {
4146
fn from(status: Status) -> Self {
42-
Self { status, data: () }
47+
Error::new(status, ())
4348
}
4449
}
4550

0 commit comments

Comments
 (0)