Skip to content

Commit 9e939bb

Browse files
authored
Merge pull request #534 from Dirbaio/feature-nightly-only
Use `feature()` on nightly toolchains only.
2 parents d9e2ca0 + c9fbac0 commit 9e939bb

File tree

8 files changed

+83
-10
lines changed

8 files changed

+83
-10
lines changed

embedded-hal-async/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use std::env;
2+
use std::ffi::OsString;
3+
use std::process::Command;
4+
5+
fn main() {
6+
println!("cargo:rerun-if-changed=build.rs");
7+
8+
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
9+
10+
let output = Command::new(rustc)
11+
.arg("--version")
12+
.output()
13+
.expect("failed to run `rustc --version`");
14+
15+
if String::from_utf8_lossy(&output.stdout).contains("nightly") {
16+
println!("cargo:rustc-cfg=nightly");
17+
}
18+
}

embedded-hal-async/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
// Needed to pass CI, because we deny warnings.
66
// We don't immediately remove them to not immediately break older nightlies.
77
// When all features are stable, we'll remove them.
8-
#![allow(stable_features)]
9-
#![allow(unknown_lints)]
8+
#![cfg_attr(nightly, allow(stable_features, unknown_lints))]
9+
#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))]
1010
#![allow(async_fn_in_trait)]
11-
#![feature(async_fn_in_trait, impl_trait_projections)]
1211

1312
pub mod delay;
1413
pub mod digital;

embedded-hal-bus/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use std::env;
2+
use std::ffi::OsString;
3+
use std::process::Command;
4+
5+
fn main() {
6+
println!("cargo:rerun-if-changed=build.rs");
7+
8+
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
9+
10+
let output = Command::new(rustc)
11+
.arg("--version")
12+
.output()
13+
.expect("failed to run `rustc --version`");
14+
15+
if String::from_utf8_lossy(&output.stdout).contains("nightly") {
16+
println!("cargo:rustc-cfg=nightly");
17+
}
18+
}

embedded-hal-bus/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
// Needed to pass CI, because we deny warnings.
77
// We don't immediately remove them to not immediately break older nightlies.
88
// When all features are stable, we'll remove them.
9-
#![cfg_attr(feature = "async", allow(stable_features))]
10-
#![cfg_attr(feature = "async", feature(async_fn_in_trait, impl_trait_projections))]
9+
#![cfg_attr(all(feature = "async", nightly), allow(stable_features))]
10+
#![cfg_attr(
11+
all(feature = "async", nightly),
12+
feature(async_fn_in_trait, impl_trait_projections)
13+
)]
1114

1215
// needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`.
1316
#[cfg(feature = "defmt-03")]

embedded-io-adapters/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use std::env;
2+
use std::ffi::OsString;
3+
use std::process::Command;
4+
5+
fn main() {
6+
println!("cargo:rerun-if-changed=build.rs");
7+
8+
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
9+
10+
let output = Command::new(rustc)
11+
.arg("--version")
12+
.output()
13+
.expect("failed to run `rustc --version`");
14+
15+
if String::from_utf8_lossy(&output.stdout).contains("nightly") {
16+
println!("cargo:rustc-cfg=nightly");
17+
}
18+
}

embedded-io-adapters/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
// We don't immediately remove them to not immediately break older nightlies.
88
// When all features are stable, we'll remove them.
99
#![cfg_attr(
10-
any(feature = "tokio-1", feature = "futures-03"),
10+
all(any(feature = "tokio-1", feature = "futures-03"), nightly),
1111
allow(stable_features)
1212
)]
1313
#![cfg_attr(
14-
any(feature = "tokio-1", feature = "futures-03"),
14+
all(any(feature = "tokio-1", feature = "futures-03"), nightly),
1515
feature(async_fn_in_trait, impl_trait_projections)
1616
)]
1717

embedded-io-async/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use std::env;
2+
use std::ffi::OsString;
3+
use std::process::Command;
4+
5+
fn main() {
6+
println!("cargo:rerun-if-changed=build.rs");
7+
8+
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
9+
10+
let output = Command::new(rustc)
11+
.arg("--version")
12+
.output()
13+
.expect("failed to run `rustc --version`");
14+
15+
if String::from_utf8_lossy(&output.stdout).contains("nightly") {
16+
println!("cargo:rustc-cfg=nightly");
17+
}
18+
}

embedded-io-async/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
// Needed to pass CI, because we deny warnings.
77
// We don't immediately remove them to not immediately break older nightlies.
88
// When all features are stable, we'll remove them.
9-
#![allow(stable_features)]
10-
#![allow(unknown_lints)]
9+
#![cfg_attr(nightly, allow(stable_features, unknown_lints))]
10+
#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))]
1111
#![allow(async_fn_in_trait)]
12-
#![feature(async_fn_in_trait, impl_trait_projections)]
1312

1413
#[cfg(feature = "alloc")]
1514
extern crate alloc;

0 commit comments

Comments
 (0)