diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b3d7608b..6b337d490 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,10 @@ other than 1. A safe alternative is to use [`Vec::into_boxed_slice`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.into_boxed_slice). - Removed `From` conversions from `ucs2::Error` to `Status` and `Error`. +- Removed use of the unstable `try_trait_v2` feature, which allowed `?` + to be used with `Status` in a function returning `uefi::Result`. This + can be replaced by calling `status.into()`, or `Result::from(status)` + in cases where the compiler needs a type hint. ## uefi-macros - [Unreleased] diff --git a/src/lib.rs b/src/lib.rs index 79f55fd13..510e63756 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,6 @@ //! For example, a PC with no network card might not contain a network driver, //! therefore all the network protocols will be unavailable. -#![feature(try_trait_v2)] #![feature(abi_efiapi)] #![feature(maybe_uninit_slice)] #![feature(negative_impls)] diff --git a/src/proto/shim/mod.rs b/src/proto/shim/mod.rs index a7f0bc2d7..c2a52b604 100644 --- a/src/proto/shim/mod.rs +++ b/src/proto/shim/mod.rs @@ -108,14 +108,14 @@ impl ShimLock { .map_err(|_| Error::from(Status::BAD_BUFFER_SIZE))?; let mut context = MaybeUninit::::uninit(); - (self.context)(ptr, size, context.as_mut_ptr())?; + Result::from((self.context)(ptr, size, context.as_mut_ptr()))?; (self.hash)( ptr, size, context.as_mut_ptr(), &mut hashes.sha256, &mut hashes.sha1, - )?; - Ok(()) + ) + .into() } } diff --git a/src/result/status.rs b/src/result/status.rs index 45391e9c7..53c0f8117 100644 --- a/src/result/status.rs +++ b/src/result/status.rs @@ -1,9 +1,5 @@ use super::{Error, Result}; -use core::{ - convert::Infallible, - ops::{ControlFlow, FromResidual, Try}, -}; -use core::{fmt::Debug, num::NonZeroUsize}; +use core::fmt::Debug; /// Bit indicating that an UEFI status code is an error const ERROR_BIT: usize = 1 << (core::mem::size_of::() * 8 - 1); @@ -172,45 +168,6 @@ impl From for Result<(), ()> { } } -pub struct StatusResidual(NonZeroUsize); - -impl Try for Status { - type Output = (); - type Residual = StatusResidual; - - fn branch(self) -> ControlFlow { - match NonZeroUsize::new(self.0) { - Some(r) => ControlFlow::Break(StatusResidual(r)), - None => ControlFlow::Continue(()), - } - } - - fn from_output(_output: Self::Output) -> Self { - Self::SUCCESS - } -} - -impl FromResidual for Status { - fn from_residual(r: StatusResidual) -> Self { - Status(r.0.into()) - } -} - -impl FromResidual for Result { - fn from_residual(r: StatusResidual) -> Self { - Err(Status(r.0.into()).into()) - } -} - -impl FromResidual> for Status { - fn from_residual(r: core::result::Result) -> Self { - match r { - Err(err) => err.status(), - Ok(infallible) => match infallible {}, - } - } -} - #[cfg(test)] mod tests { use super::*;