Skip to content

Commit 79785ec

Browse files
committed
Always set #![no_std] and remove redundant imports
``` error: the item `Box` is imported redundantly --> futures-core/src/future.rs:89:9 | 89 | use alloc::boxed::Box; | ^^^^^^^^^^^^^^^^^ --> /rustc/381d69953bb7c3390cec0fee200f24529cb6320f/library/std/src/prelude/mod.rs:115:13 | = note: the item `Box` is already defined here | = note: `-D unused-imports` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_imports)]` error: the item `Box` is imported redundantly --> futures-core/src/stream.rs:203:9 | 203 | use alloc::boxed::Box; | ^^^^^^^^^^^^^^^^^ --> /rustc/381d69953bb7c3390cec0fee200f24529cb6320f/library/std/src/prelude/mod.rs:115:13 | = note: the item `Box` is already defined here ```
1 parent 021241b commit 79785ec

File tree

31 files changed

+78
-33
lines changed

31 files changed

+78
-33
lines changed

futures-channel/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@
1111
//! All items are only available when the `std` or `alloc` feature of this
1212
//! library is activated, and it is activated by default.
1313
14-
#![cfg_attr(not(feature = "std"), no_std)]
15-
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
14+
#![no_std]
1615
#![doc(test(
1716
no_crate_inject,
1817
attr(
1918
deny(warnings, rust_2018_idioms, single_use_lifetimes),
2019
allow(dead_code, unused_assignments, unused_variables)
2120
)
2221
))]
22+
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
2323
#![allow(clippy::arc_with_non_send_sync)] // false positive https://github.com/rust-lang/rust-clippy/issues/11076
2424

2525
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
2626
#[cfg(feature = "alloc")]
2727
extern crate alloc;
28+
#[cfg(feature = "std")]
29+
extern crate std;
2830

2931
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
3032
#[cfg(feature = "alloc")]

futures-channel/src/mpsc/queue.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
pub(super) use self::PopResult::*;
4545

46+
use std::boxed::Box;
4647
use std::cell::UnsafeCell;
4748
use std::ptr;
4849
use std::sync::atomic::{AtomicPtr, Ordering};

futures-core/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
//! Core traits and types for asynchronous operations in Rust.
22
3-
#![cfg_attr(not(feature = "std"), no_std)]
4-
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
3+
#![no_std]
54
#![doc(test(
65
no_crate_inject,
76
attr(
87
deny(warnings, rust_2018_idioms, single_use_lifetimes),
98
allow(dead_code, unused_assignments, unused_variables)
109
)
1110
))]
11+
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
1212

1313
#[cfg(feature = "alloc")]
1414
extern crate alloc;
15+
#[cfg(feature = "std")]
16+
extern crate std;
1517

1618
pub mod future;
1719
#[doc(no_inline)]

futures-executor/src/enter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cell::Cell;
22
use std::fmt;
33

4-
thread_local!(static ENTERED: Cell<bool> = Cell::new(false));
4+
std::thread_local!(static ENTERED: Cell<bool> = Cell::new(false));
55

66
/// Represents an executor context.
77
///

futures-executor/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,21 @@
3636
//! [`spawn_obj`]: https://docs.rs/futures/0.3/futures/task/trait.Spawn.html#tymethod.spawn_obj
3737
//! [`spawn_local_obj`]: https://docs.rs/futures/0.3/futures/task/trait.LocalSpawn.html#tymethod.spawn_local_obj
3838
39-
#![cfg_attr(not(feature = "std"), no_std)]
40-
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
39+
#![no_std]
4140
#![doc(test(
4241
no_crate_inject,
4342
attr(
4443
deny(warnings, rust_2018_idioms, single_use_lifetimes),
4544
allow(dead_code, unused_assignments, unused_variables)
4645
)
4746
))]
47+
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
4848
#![cfg_attr(docsrs, feature(doc_cfg))]
4949
#![allow(clippy::thread_local_initializer_can_be_made_const)] // clippy bug: this lint doesn't consider MSRV
5050

51+
#[cfg(feature = "std")]
52+
extern crate std;
53+
5154
#[cfg(feature = "std")]
5255
mod local_pool;
5356
#[cfg(feature = "std")]

futures-executor/src/local_pool.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::sync::{
1515
Arc,
1616
};
1717
use std::thread::{self, Thread};
18+
use std::vec::Vec;
1819

1920
/// A single-threaded task pool for polling futures to completion.
2021
///
@@ -53,7 +54,7 @@ pub(crate) struct ThreadNotify {
5354
unparked: AtomicBool,
5455
}
5556

56-
thread_local! {
57+
std::thread_local! {
5758
static CURRENT_THREAD_NOTIFY: Arc<ThreadNotify> = Arc::new(ThreadNotify {
5859
thread: thread::current(),
5960
unparked: AtomicBool::new(false),

futures-executor/src/thread_pool.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ use futures_core::task::{Context, Poll};
55
use futures_task::{waker_ref, ArcWake};
66
use futures_task::{FutureObj, Spawn, SpawnError};
77
use futures_util::future::FutureExt;
8+
use std::boxed::Box;
89
use std::cmp;
910
use std::fmt;
11+
use std::format;
1012
use std::io;
13+
use std::string::String;
1114
use std::sync::atomic::{AtomicUsize, Ordering};
1215
use std::sync::mpsc;
1316
use std::sync::{Arc, Mutex};
@@ -358,7 +361,6 @@ impl ArcWake for WakeHandle {
358361
#[cfg(test)]
359362
mod tests {
360363
use super::*;
361-
use std::sync::mpsc;
362364

363365
#[test]
364366
fn test_drop_after_start() {

futures-io/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,28 @@
88
//! All items of this library are only available when the `std` feature of this
99
//! library is activated, and it is activated by default.
1010
11-
#![cfg_attr(not(feature = "std"), no_std)]
12-
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
11+
#![no_std]
1312
#![doc(test(
1413
no_crate_inject,
1514
attr(
1615
deny(warnings, rust_2018_idioms, single_use_lifetimes),
1716
allow(dead_code, unused_assignments, unused_variables)
1817
)
1918
))]
19+
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
2020
#![cfg_attr(docsrs, feature(doc_cfg))]
2121

22+
#[cfg(feature = "std")]
23+
extern crate std;
24+
2225
#[cfg(feature = "std")]
2326
mod if_std {
27+
use std::boxed::Box;
2428
use std::io;
2529
use std::ops::DerefMut;
2630
use std::pin::Pin;
2731
use std::task::{Context, Poll};
32+
use std::vec::Vec;
2833

2934
// Re-export some types from `std::io` so that users don't have to deal
3035
// with conflicts when `use`ing `futures::io` and `std::io`.

futures-sink/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
//! This crate contains the `Sink` trait which allows values to be sent
44
//! asynchronously.
55
6-
#![cfg_attr(not(feature = "std"), no_std)]
7-
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
6+
#![no_std]
87
#![doc(test(
98
no_crate_inject,
109
attr(
1110
deny(warnings, rust_2018_idioms, single_use_lifetimes),
1211
allow(dead_code, unused_assignments, unused_variables)
1312
)
1413
))]
14+
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
1515

1616
#[cfg(feature = "alloc")]
1717
extern crate alloc;
18+
#[cfg(feature = "std")]
19+
extern crate std;
1820

1921
use core::ops::DerefMut;
2022
use core::pin::Pin;

futures-task/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
//! Tools for working with tasks.
22
3-
#![cfg_attr(not(feature = "std"), no_std)]
4-
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
3+
#![no_std]
54
#![doc(test(
65
no_crate_inject,
76
attr(
87
deny(warnings, rust_2018_idioms, single_use_lifetimes),
98
allow(dead_code, unused_assignments, unused_variables)
109
)
1110
))]
11+
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
1212

1313
#[cfg(feature = "alloc")]
1414
extern crate alloc;
15+
#[cfg(feature = "std")]
16+
extern crate std;
1517

1618
mod spawn;
1719
pub use crate::spawn::{LocalSpawn, Spawn, SpawnError};

0 commit comments

Comments
 (0)