diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index 2450ae61b..7141fe0f9 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -57,9 +57,6 @@ avr-device = { version = "0.5.3", optional = true } critical-section = { version = "1.1", features = ["std"] } trybuild = "1.0" -[build-dependencies] -rustc_version = "0.4.1" - [features] ## Enable nightly-only features diff --git a/embassy-executor/build.rs b/embassy-executor/build.rs index c4c86e1e2..8a41d7503 100644 --- a/embassy-executor/build.rs +++ b/embassy-executor/build.rs @@ -96,15 +96,4 @@ fn main() { let mut rustc_cfgs = common::CfgSet::new(); common::set_target_cfgs(&mut rustc_cfgs); - - // Waker API changed on 2024-09-06 - rustc_cfgs.declare("at_least_2024_09_06"); - let Some(compiler) = common::compiler_info() else { - return; - }; - if compiler.channel == rustc_version::Channel::Nightly - && compiler.commit_date.map(|d| d >= "2024-09-06").unwrap_or(false) - { - rustc_cfgs.enable("at_least_2024_09_06"); - } } diff --git a/embassy-executor/build_common.rs b/embassy-executor/build_common.rs index af6bb0618..b15a8369f 100644 --- a/embassy-executor/build_common.rs +++ b/embassy-executor/build_common.rs @@ -124,22 +124,3 @@ impl PartialOrd<&str> for CompilerDate { Self::parse(other).map(|other| self.cmp(&other)) } } - -pub struct CompilerInfo { - #[allow(unused)] - pub version: rustc_version::Version, - pub channel: rustc_version::Channel, - pub commit_date: Option, -} - -pub fn compiler_info() -> Option { - let Ok(meta) = rustc_version::version_meta() else { - return None; - }; - - Some(CompilerInfo { - version: meta.semver, - channel: meta.channel, - commit_date: meta.commit_date.as_deref().and_then(CompilerDate::parse), - }) -} diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index 8e07a8b18..d816539ac 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)] -#![cfg_attr(all(feature = "nightly", not(at_least_2024_09_06)), feature(waker_getters))] #![allow(clippy::new_without_default)] #![doc = include_str!("../README.md")] #![warn(missing_docs)] diff --git a/embassy-executor/src/raw/waker.rs b/embassy-executor/src/raw/waker.rs index 30b8cdd4c..d2256adfa 100644 --- a/embassy-executor/src/raw/waker.rs +++ b/embassy-executor/src/raw/waker.rs @@ -32,40 +32,20 @@ pub(crate) unsafe fn from_task(p: TaskRef) -> Waker { /// /// Panics if the waker is not created by the Embassy executor. pub fn task_from_waker(waker: &Waker) -> TaskRef { - let (vtable, data) = { - #[cfg(not(feature = "nightly"))] - { - struct WakerHack { - data: *const (), - vtable: &'static RawWakerVTable, - } + struct WakerHack { + data: *const (), + vtable: &'static RawWakerVTable, + } - // safety: OK because WakerHack has the same layout as Waker. - // This is not really guaranteed because the structs are `repr(Rust)`, it is - // indeed the case in the current implementation. - // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992 - let hack: &WakerHack = unsafe { core::mem::transmute(waker) }; - (hack.vtable, hack.data) - } + // safety: OK because WakerHack has the same layout as Waker. + // This is not really guaranteed because the structs are `repr(Rust)`, it is + // indeed the case in the current implementation. + // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992 + let hack: &WakerHack = unsafe { core::mem::transmute(waker) }; - #[cfg(feature = "nightly")] - { - #[cfg(not(at_least_2024_09_06))] - { - let raw_waker = waker.as_raw(); - (raw_waker.vtable(), raw_waker.data()) - } - - #[cfg(at_least_2024_09_06)] - { - (waker.vtable(), waker.data()) - } - } - }; - - if vtable != &VTABLE { + if hack.vtable != &VTABLE { panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.") } // safety: our wakers are always created with `TaskRef::as_ptr` - unsafe { TaskRef::from_ptr(data as *const TaskHeader) } + unsafe { TaskRef::from_ptr(hack.data as *const TaskHeader) } }