From aedcc472c9fa133f73fcf3a6139d178c81159452 Mon Sep 17 00:00:00 2001
From: Gabriel Smith <ga29smith@gmail.com>
Date: Sun, 27 Nov 2022 17:59:01 -0500
Subject: [PATCH] time: Fix nighly feature compilation after upgrade to
 embedded-hal-async 0.2.0-alpha.0

---
 embassy-time/src/delay.rs | 16 ++++------------
 embassy-time/src/lib.rs   |  3 ++-
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs
index ff6b6869a..0ca176abd 100644
--- a/embassy-time/src/delay.rs
+++ b/embassy-time/src/delay.rs
@@ -33,26 +33,18 @@ mod eh1 {
 
 #[cfg(all(feature = "unstable-traits", feature = "nightly"))]
 mod eha {
-    use core::future::Future;
-
-    use futures_util::FutureExt;
-
     use super::*;
     use crate::Timer;
 
     impl embedded_hal_async::delay::DelayUs for Delay {
         type Error = core::convert::Infallible;
 
-        type DelayUsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
-
-        fn delay_us(&mut self, micros: u32) -> Self::DelayUsFuture<'_> {
-            Timer::after(Duration::from_micros(micros as _)).map(Ok)
+        async fn delay_us(&mut self, micros: u32) -> Result<(), Self::Error> {
+            Ok(Timer::after(Duration::from_micros(micros as _)).await)
         }
 
-        type DelayMsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
-
-        fn delay_ms(&mut self, millis: u32) -> Self::DelayMsFuture<'_> {
-            Timer::after(Duration::from_millis(millis as _)).map(Ok)
+        async fn delay_ms(&mut self, millis: u32) -> Result<(), Self::Error> {
+            Ok(Timer::after(Duration::from_millis(millis as _)).await)
         }
     }
 }
diff --git a/embassy-time/src/lib.rs b/embassy-time/src/lib.rs
index 586aa28de..8b0aebe19 100644
--- a/embassy-time/src/lib.rs
+++ b/embassy-time/src/lib.rs
@@ -1,5 +1,6 @@
 #![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)]
-#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))]
+#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
+#![cfg_attr(feature = "nightly", allow(incomplete_features))]
 #![doc = include_str!("../README.md")]
 #![allow(clippy::new_without_default)]
 #![warn(missing_docs)]