From f2cc919cdad76842cfdab409560923a9fd4590cf Mon Sep 17 00:00:00 2001
From: Tim Crawford <tcrawford@system76.com>
Date: Tue, 19 Oct 2021 09:19:40 -0600
Subject: [PATCH] Update uefi dep, fix building on nightly

The UEFI crate has been updated to use try_trait_v2, which changes how
Status is used.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
---
 Cargo.toml |  2 +-
 src/lib.rs | 19 +++++++++----------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index e7055fb..d22d232 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,4 +11,4 @@ repository = "https://gitlab.redox-os.org/redox-os/uefi_alloc"
 name = "uefi_alloc"
 
 [dependencies]
-redox_uefi = "0.1.0"
+redox_uefi = "0.1.2"
diff --git a/src/lib.rs b/src/lib.rs
index 4d14d2f..ab481c6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,10 +1,10 @@
 #![feature(allocator_api)]
-#![feature(const_fn)]
-#![feature(try_trait)]
+#![feature(try_trait_v2)]
+#![feature(control_flow_enum)]
 #![no_std]
 
 use core::alloc::{GlobalAlloc, Layout};
-use core::ops::Try;
+use core::ops::{ControlFlow, Try};
 use core::ptr::{self, NonNull};
 use uefi::memory::MemoryType;
 use uefi::system::SystemTable;
@@ -21,17 +21,16 @@ unsafe impl GlobalAlloc for Allocator {
     unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
         let uefi = UEFI.expect("__rust_allocate: uefi not initialized");
         let mut ptr = 0;
-        if (uefi.as_ref().BootServices.AllocatePool)(
+        let res = (uefi.as_ref().BootServices.AllocatePool)(
             MemoryType::EfiLoaderData,
             layout.size(),
             &mut ptr,
         )
-        .into_result()
-        .is_ok()
-        {
-            ptr as *mut u8
-        } else {
-            ptr::null_mut()
+        .branch();
+
+        match res {
+            ControlFlow::Continue(ptr) => ptr as *mut u8,
+            ControlFlow::Break(_) => ptr::null_mut(),
         }
     }
 
-- 
GitLab