mirror of
https://github.com/rust-lang/futures-rs.git
synced 2026-01-25 03:26:14 +00:00
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
```
This commit is contained in:
@@ -11,8 +11,7 @@
|
||||
//! All items are only available when the `std` or `alloc` feature of this
|
||||
//! library is activated, and it is activated by default.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![no_std]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -20,11 +19,14 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![allow(clippy::arc_with_non_send_sync)] // false positive https://github.com/rust-lang/rust-clippy/issues/11076
|
||||
|
||||
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
|
||||
#[cfg(feature = "alloc")]
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
pub(super) use self::PopResult::*;
|
||||
|
||||
use std::boxed::Box;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! Core traits and types for asynchronous operations in Rust.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
|
||||
#![no_std]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -9,9 +8,12 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
pub mod future;
|
||||
#[doc(no_inline)]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::cell::Cell;
|
||||
use std::fmt;
|
||||
|
||||
thread_local!(static ENTERED: Cell<bool> = Cell::new(false));
|
||||
std::thread_local!(static ENTERED: Cell<bool> = Cell::new(false));
|
||||
|
||||
/// Represents an executor context.
|
||||
///
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
//! [`spawn_obj`]: https://docs.rs/futures/0.3/futures/task/trait.Spawn.html#tymethod.spawn_obj
|
||||
//! [`spawn_local_obj`]: https://docs.rs/futures/0.3/futures/task/trait.LocalSpawn.html#tymethod.spawn_local_obj
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![no_std]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -45,9 +44,13 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![allow(clippy::thread_local_initializer_can_be_made_const)] // clippy bug: this lint doesn't consider MSRV
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod local_pool;
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -15,6 +15,7 @@ use std::sync::{
|
||||
Arc,
|
||||
};
|
||||
use std::thread::{self, Thread};
|
||||
use std::vec::Vec;
|
||||
|
||||
/// A single-threaded task pool for polling futures to completion.
|
||||
///
|
||||
@@ -53,7 +54,7 @@ pub(crate) struct ThreadNotify {
|
||||
unparked: AtomicBool,
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
std::thread_local! {
|
||||
static CURRENT_THREAD_NOTIFY: Arc<ThreadNotify> = Arc::new(ThreadNotify {
|
||||
thread: thread::current(),
|
||||
unparked: AtomicBool::new(false),
|
||||
|
||||
@@ -5,9 +5,12 @@ use futures_core::task::{Context, Poll};
|
||||
use futures_task::{waker_ref, ArcWake};
|
||||
use futures_task::{FutureObj, Spawn, SpawnError};
|
||||
use futures_util::future::FutureExt;
|
||||
use std::boxed::Box;
|
||||
use std::cmp;
|
||||
use std::fmt;
|
||||
use std::format;
|
||||
use std::io;
|
||||
use std::string::String;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::mpsc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -358,7 +361,6 @@ impl ArcWake for WakeHandle {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::sync::mpsc;
|
||||
|
||||
#[test]
|
||||
fn test_drop_after_start() {
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
//! All items of this library are only available when the `std` feature of this
|
||||
//! library is activated, and it is activated by default.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
|
||||
#![no_std]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -17,14 +16,20 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod if_std {
|
||||
use std::boxed::Box;
|
||||
use std::io;
|
||||
use std::ops::DerefMut;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use std::vec::Vec;
|
||||
|
||||
// Re-export some types from `std::io` so that users don't have to deal
|
||||
// with conflicts when `use`ing `futures::io` and `std::io`.
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
//! This crate contains the `Sink` trait which allows values to be sent
|
||||
//! asynchronously.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
|
||||
#![no_std]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -12,9 +11,12 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
use core::ops::DerefMut;
|
||||
use core::pin::Pin;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! Tools for working with tasks.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![no_std]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -9,9 +8,12 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
mod spawn;
|
||||
pub use crate::spawn::{LocalSpawn, Spawn, SpawnError};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//! Utilities to make testing [`Future`s](futures_core::future::Future) easier
|
||||
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -8,6 +7,7 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![allow(clippy::test_attr_in_doctest)]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
|
||||
@@ -25,7 +25,7 @@ fn gen_index(n: usize) -> usize {
|
||||
///
|
||||
/// [xorshift*]: https://en.wikipedia.org/wiki/Xorshift#xorshift*
|
||||
fn random() -> u64 {
|
||||
thread_local! {
|
||||
std::thread_local! {
|
||||
static RNG: Cell<Wrapping<u64>> = Cell::new(Wrapping(prng_seed()));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use futures_01::{AsyncSink as AsyncSink01, Sink as Sink01};
|
||||
use futures_core::{future::Future as Future03, stream::Stream as Stream03, task as task03};
|
||||
#[cfg(feature = "sink")]
|
||||
use futures_sink::Sink as Sink03;
|
||||
use std::boxed::Box;
|
||||
use std::pin::Pin;
|
||||
use std::task::Context;
|
||||
|
||||
|
||||
@@ -201,8 +201,6 @@ where
|
||||
mod if_std {
|
||||
use super::*;
|
||||
|
||||
use core::pin::Pin;
|
||||
use core::task::{Context, Poll};
|
||||
use futures_io::{
|
||||
AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, IoSlice, IoSliceMut, Result, SeekFrom,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use core::any::Any;
|
||||
use core::pin::Pin;
|
||||
use std::boxed::Box;
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe, UnwindSafe};
|
||||
|
||||
use futures_core::future::Future;
|
||||
|
||||
@@ -9,6 +9,7 @@ use {
|
||||
pin_project_lite::pin_project,
|
||||
std::{
|
||||
any::Any,
|
||||
boxed::Box,
|
||||
fmt,
|
||||
panic::{self, AssertUnwindSafe},
|
||||
pin::Pin,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use futures_core::task::{Context, Poll};
|
||||
use futures_io::{AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, IoSlice, IoSliceMut, SeekFrom};
|
||||
use std::pin::Pin;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
use std::{fmt, io};
|
||||
|
||||
/// A simple wrapper type which allows types which implement only
|
||||
|
||||
@@ -4,8 +4,10 @@ use futures_core::ready;
|
||||
use futures_core::task::{Context, Poll};
|
||||
use futures_io::{AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, IoSliceMut, SeekFrom};
|
||||
use pin_project_lite::pin_project;
|
||||
use std::boxed::Box;
|
||||
use std::io::{self, Read};
|
||||
use std::pin::Pin;
|
||||
use std::vec;
|
||||
use std::{cmp, fmt};
|
||||
|
||||
pin_project! {
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::fmt;
|
||||
use std::io::{self, Write};
|
||||
use std::pin::Pin;
|
||||
use std::ptr;
|
||||
use std::vec::Vec;
|
||||
|
||||
pin_project! {
|
||||
/// Wraps a writer and buffers its output.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use futures_core::task::{Context, Poll};
|
||||
use futures_io::{AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, IoSlice, IoSliceMut, SeekFrom};
|
||||
use std::boxed::Box;
|
||||
use std::io;
|
||||
use std::pin::Pin;
|
||||
use std::vec::Vec;
|
||||
|
||||
/// A `Cursor` wraps an in-memory buffer and provides it with a
|
||||
/// [`AsyncSeek`] implementation.
|
||||
|
||||
@@ -7,6 +7,8 @@ use pin_project_lite::pin_project;
|
||||
use std::io;
|
||||
use std::mem;
|
||||
use std::pin::Pin;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
|
||||
pin_project! {
|
||||
/// Stream for the [`lines`](super::AsyncBufReadExt::lines) method.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use crate::compat::Compat;
|
||||
use crate::future::assert_future;
|
||||
use crate::stream::assert_stream;
|
||||
use std::{pin::Pin, ptr};
|
||||
use std::{pin::Pin, ptr, string::String, vec::Vec};
|
||||
|
||||
// Re-export some types from `std::io` so that users don't have to deal
|
||||
// with conflicts when `use`ing `futures::io` and `std::io`.
|
||||
|
||||
@@ -7,6 +7,8 @@ use std::io;
|
||||
use std::mem;
|
||||
use std::pin::Pin;
|
||||
use std::str;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
|
||||
/// Future for the [`read_line`](super::AsyncBufReadExt::read_line) method.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -4,6 +4,7 @@ use futures_core::ready;
|
||||
use futures_core::task::{Context, Poll};
|
||||
use futures_io::AsyncRead;
|
||||
use std::pin::Pin;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
use std::{io, mem, str};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use futures_io::AsyncBufRead;
|
||||
use std::io;
|
||||
use std::mem;
|
||||
use std::pin::Pin;
|
||||
use std::vec::Vec;
|
||||
|
||||
/// Future for the [`read_until`](super::AsyncBufReadExt::read_until) method.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -49,6 +49,8 @@ mod tests {
|
||||
use std::io;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use std::vec;
|
||||
use std::vec::Vec;
|
||||
|
||||
use crate::io::{AsyncWrite, AsyncWriteExt, IoSlice};
|
||||
use crate::task::noop_waker;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
//! Combinators and utilities for working with `Future`s, `Stream`s, `Sink`s,
|
||||
//! and the `AsyncRead` and `AsyncWrite` traits.
|
||||
|
||||
#![cfg_attr(feature = "write-all-vectored", feature(io_slice_advance))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![no_std]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -11,6 +9,8 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![cfg_attr(feature = "write-all-vectored", feature(io_slice_advance))]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![allow(clippy::needless_borrow)] // https://github.com/rust-lang/futures-rs/pull/2558#issuecomment-1030745203
|
||||
#![allow(clippy::arc_with_non_send_sync)] // false positive https://github.com/rust-lang/rust-clippy/issues/11076
|
||||
@@ -20,6 +20,8 @@ compile_error!("The `bilock` feature requires the `unstable` feature as an expli
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
// Macro re-exports
|
||||
pub use futures_core::ready;
|
||||
|
||||
@@ -544,11 +544,17 @@ unsafe impl<T: ?Sized + Sync> Sync for OwnedMutexGuard<T> {}
|
||||
unsafe impl<T: ?Sized + Send, U: ?Sized + Send> Send for MappedMutexGuard<'_, T, U> {}
|
||||
unsafe impl<T: ?Sized + Sync, U: ?Sized + Sync> Sync for MappedMutexGuard<'_, T, U> {}
|
||||
|
||||
#[test]
|
||||
fn test_mutex_guard_debug_not_recurse() {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::format;
|
||||
|
||||
#[test]
|
||||
fn test_mutex_guard_debug_not_recurse() {
|
||||
let mutex = Mutex::new(42);
|
||||
let guard = mutex.try_lock().unwrap();
|
||||
let _ = format!("{:?}", guard);
|
||||
let guard = MutexGuard::map(guard, |n| n);
|
||||
let _ = format!("{:?}", guard);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use futures_core::stream::{FusedStream, Stream};
|
||||
use futures_core::task::{Context, Poll};
|
||||
use pin_project_lite::pin_project;
|
||||
use std::any::Any;
|
||||
use std::boxed::Box;
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe, UnwindSafe};
|
||||
use std::pin::Pin;
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ impl<T: core::any::Any, Item> std::error::Error for ReuniteError<T, Item> {}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{sink::Sink, stream::StreamExt};
|
||||
use crate::stream::StreamExt;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
struct NopStream<Item> {
|
||||
|
||||
@@ -81,8 +81,7 @@
|
||||
//! The majority of examples and code snippets in this crate assume that they are
|
||||
//! inside an async block as written above.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![no_std]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(
|
||||
@@ -90,6 +89,7 @@
|
||||
allow(dead_code, unused_assignments, unused_variables)
|
||||
)
|
||||
))]
|
||||
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
#[cfg(all(feature = "bilock", not(feature = "unstable")))]
|
||||
|
||||
Reference in New Issue
Block a user