diff --git a/embedded-hal-async/build.rs b/embedded-hal-async/build.rs new file mode 100644 index 000000000..78bd27ec7 --- /dev/null +++ b/embedded-hal-async/build.rs @@ -0,0 +1,18 @@ +use std::env; +use std::ffi::OsString; +use std::process::Command; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + let output = Command::new(rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`"); + + if String::from_utf8_lossy(&output.stdout).contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } +} diff --git a/embedded-hal-async/src/lib.rs b/embedded-hal-async/src/lib.rs index cc3060708..44901deca 100644 --- a/embedded-hal-async/src/lib.rs +++ b/embedded-hal-async/src/lib.rs @@ -5,10 +5,9 @@ // Needed to pass CI, because we deny warnings. // We don't immediately remove them to not immediately break older nightlies. // When all features are stable, we'll remove them. -#![allow(stable_features)] -#![allow(unknown_lints)] +#![cfg_attr(nightly, allow(stable_features, unknown_lints))] +#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] #![allow(async_fn_in_trait)] -#![feature(async_fn_in_trait, impl_trait_projections)] pub mod delay; pub mod digital; diff --git a/embedded-hal-bus/build.rs b/embedded-hal-bus/build.rs new file mode 100644 index 000000000..78bd27ec7 --- /dev/null +++ b/embedded-hal-bus/build.rs @@ -0,0 +1,18 @@ +use std::env; +use std::ffi::OsString; +use std::process::Command; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + let output = Command::new(rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`"); + + if String::from_utf8_lossy(&output.stdout).contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } +} diff --git a/embedded-hal-bus/src/lib.rs b/embedded-hal-bus/src/lib.rs index 501534947..e7e75ec76 100644 --- a/embedded-hal-bus/src/lib.rs +++ b/embedded-hal-bus/src/lib.rs @@ -6,8 +6,11 @@ // Needed to pass CI, because we deny warnings. // We don't immediately remove them to not immediately break older nightlies. // When all features are stable, we'll remove them. -#![cfg_attr(feature = "async", allow(stable_features))] -#![cfg_attr(feature = "async", feature(async_fn_in_trait, impl_trait_projections))] +#![cfg_attr(all(feature = "async", nightly), allow(stable_features))] +#![cfg_attr( + all(feature = "async", nightly), + feature(async_fn_in_trait, impl_trait_projections) +)] // needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`. #[cfg(feature = "defmt-03")] diff --git a/embedded-io-adapters/build.rs b/embedded-io-adapters/build.rs new file mode 100644 index 000000000..78bd27ec7 --- /dev/null +++ b/embedded-io-adapters/build.rs @@ -0,0 +1,18 @@ +use std::env; +use std::ffi::OsString; +use std::process::Command; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + let output = Command::new(rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`"); + + if String::from_utf8_lossy(&output.stdout).contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } +} diff --git a/embedded-io-adapters/src/lib.rs b/embedded-io-adapters/src/lib.rs index 533acc1a7..f9d0f1a5c 100644 --- a/embedded-io-adapters/src/lib.rs +++ b/embedded-io-adapters/src/lib.rs @@ -7,11 +7,11 @@ // We don't immediately remove them to not immediately break older nightlies. // When all features are stable, we'll remove them. #![cfg_attr( - any(feature = "tokio-1", feature = "futures-03"), + all(any(feature = "tokio-1", feature = "futures-03"), nightly), allow(stable_features) )] #![cfg_attr( - any(feature = "tokio-1", feature = "futures-03"), + all(any(feature = "tokio-1", feature = "futures-03"), nightly), feature(async_fn_in_trait, impl_trait_projections) )] diff --git a/embedded-io-async/build.rs b/embedded-io-async/build.rs new file mode 100644 index 000000000..78bd27ec7 --- /dev/null +++ b/embedded-io-async/build.rs @@ -0,0 +1,18 @@ +use std::env; +use std::ffi::OsString; +use std::process::Command; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + let output = Command::new(rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`"); + + if String::from_utf8_lossy(&output.stdout).contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } +} diff --git a/embedded-io-async/src/lib.rs b/embedded-io-async/src/lib.rs index 2970aa82f..1171d42a0 100644 --- a/embedded-io-async/src/lib.rs +++ b/embedded-io-async/src/lib.rs @@ -6,10 +6,9 @@ // Needed to pass CI, because we deny warnings. // We don't immediately remove them to not immediately break older nightlies. // When all features are stable, we'll remove them. -#![allow(stable_features)] -#![allow(unknown_lints)] +#![cfg_attr(nightly, allow(stable_features, unknown_lints))] +#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] #![allow(async_fn_in_trait)] -#![feature(async_fn_in_trait, impl_trait_projections)] #[cfg(feature = "alloc")] extern crate alloc;