Skip to content

Commit 57eafb4

Browse files
committed
silence warnings reported by newer rust versions
1 parent 79c89d7 commit 57eafb4

File tree

13 files changed

+27
-22
lines changed

13 files changed

+27
-22
lines changed

examples/a-chat/server.rs

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ async fn connection_writer_loop(
9696
None => break,
9797
},
9898
void = shutdown.next().fuse() => match void {
99+
#[allow(unreachable_patterns)]
99100
Some(void) => match void {},
100101
None => break,
101102
}

src/future/future/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub use core::future::Future as Future;
2727
2828
[`Future`]: ../future/trait.Future.html
2929
"#]
30+
#[cfg(any(feature = "std", feature = "docs"))]
3031
pub trait FutureExt: Future {
3132
/// Returns a Future that delays execution for a specified time.
3233
///
@@ -284,5 +285,6 @@ pub trait FutureExt: Future {
284285
}
285286
}
286287

288+
#[cfg(any(feature = "std", feature = "docs"))]
287289
impl<T: Future + ?Sized> FutureExt for T {}
288290

src/io/buf_writer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pin_project! {
114114
/// # Ok(()) }) }
115115
///```
116116
#[derive(Debug)]
117-
pub struct IntoInnerError<W>(W, crate::io::Error);
117+
pub struct IntoInnerError<W>(W, #[allow(dead_code)] crate::io::Error);
118118

119119
impl<W: Write> BufWriter<W> {
120120
/// Creates a new `BufWriter` with a default buffer capacity. The default is currently 8 KB,

src/io/read/bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<T: Read + Unpin> Stream for Bytes<T> {
3232
}
3333
}
3434

35-
#[cfg(all(test, default))]
35+
#[cfg(all(test, feature = "default", not(target_arch = "wasm32")))]
3636
mod tests {
3737
use crate::io;
3838
use crate::prelude::*;

src/io/read/chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
165165
}
166166
}
167167

168-
#[cfg(all(test, default))]
168+
#[cfg(all(test, feature = "default", not(target_arch = "wasm32")))]
169169
mod tests {
170170
use crate::io;
171171
use crate::prelude::*;

src/io/stderr.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,13 @@ cfg_windows! {
204204
}
205205

206206
cfg_io_safety! {
207-
use crate::os::unix::io::{AsHandle, BorrowedHandle};
207+
use crate::os::windows::io::{AsHandle, BorrowedHandle};
208208

209209
impl AsHandle for Stderr {
210210
fn as_handle(&self) -> BorrowedHandle<'_> {
211-
std::io::stderr().as_handle()
211+
unsafe {
212+
BorrowedHandle::borrow_raw(std::io::stderr().as_raw_handle())
213+
}
212214
}
213215
}
214216
}

src/io/stdin.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@ cfg_windows! {
230230
}
231231

232232
cfg_io_safety! {
233-
use crate::os::unix::io::{AsFd, BorrowedFd};
233+
use crate::os::windows::io::{AsHandle, BorrowedHandle};
234234

235-
impl AsFd for Stdin {
236-
fn as_fd(&self) -> BorrowedFd<'_> {
237-
std::io::stdin().as_fd()
235+
impl AsHandle for Stdin {
236+
fn as_handle(&self) -> BorrowedHandle<'_> {
237+
unsafe {
238+
BorrowedHandle::borrow_raw(std::io::stdin().as_raw_handle())
239+
}
238240
}
239241
}
240242
}

src/io/stdout.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,13 @@ cfg_windows! {
204204
}
205205

206206
cfg_io_safety! {
207-
use crate::os::unix::io::{AsHandle, BorrowedHandle};
207+
use crate::os::windows::io::{AsHandle, BorrowedHandle};
208208

209209
impl AsHandle for Stdout {
210210
fn as_handle(&self) -> BorrowedHandle<'_> {
211-
std::io::stdout().as_handle()
211+
unsafe {
212+
BorrowedHandle::borrow_raw(std::io::stdout().as_raw_handle())
213+
}
212214
}
213215
}
214216
}

src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@
284284
#![doc(test(attr(allow(unused_extern_crates, unused_variables))))]
285285
#![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")]
286286

287-
extern crate alloc;
288-
289287
#[macro_use]
290288
mod utils;
291289

src/net/tcp/stream.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,13 @@ cfg_windows! {
477477

478478
impl From<OwnedSocket> for TcpStream {
479479
fn from(fd: OwnedSocket) -> TcpStream {
480-
std::net::TcpListener::from(fd).into()
480+
std::net::TcpStream::from(fd).into()
481481
}
482482
}
483483

484484
impl From<TcpStream> for OwnedSocket {
485485
fn from(stream: TcpStream) -> OwnedSocket {
486-
stream.watcher.into_inner().unwrap().into()
486+
stream.watcher.get_ref().try_clone().unwrap().into()
487487
}
488488
}
489489
}

src/net/udp/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ cfg_windows! {
620620

621621
impl From<OwnedSocket> for UdpSocket {
622622
fn from(fd: OwnedSocket) -> UdpSocket {
623-
std::net::TcpListener::from(fd).into()
623+
std::net::UdpSocket::from(fd).into()
624624
}
625625
}
626626

src/stream/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
//! [`Stream`] looks like this:
3535
//!
3636
//! ```
37+
//! #![allow(dead_code)]
3738
//! # use async_std::task::{Context, Poll};
3839
//! # use std::pin::Pin;
39-
//! trait Stream {
40+
//! pub trait Stream {
4041
//! type Item;
4142
//! fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>;
4243
//! }

src/utils.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use alloc::string::String;
2-
31
/// Calls a function and aborts if it panics.
42
///
53
/// This is useful in unsafe code where we can't recover from panics.
@@ -55,6 +53,7 @@ pub fn random(n: u32) -> u32 {
5553
}
5654

5755
/// Add additional context to errors
56+
#[cfg(feature = "std")]
5857
pub(crate) trait Context {
5958
fn context(self, message: impl Fn() -> String) -> Self;
6059
}
@@ -148,7 +147,7 @@ macro_rules! cfg_unstable_default {
148147
($($item:item)*) => {
149148
$(
150149
#[cfg(all(feature = "default", feature = "unstable"))]
151-
#[cfg_attr(feature = "docs", doc(unstable))]
150+
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
152151
$item
153152
)*
154153
}
@@ -161,7 +160,6 @@ macro_rules! cfg_unix {
161160
($($item:item)*) => {
162161
$(
163162
#[cfg(any(unix, feature = "docs"))]
164-
#[cfg_attr(feature = "docs", doc(cfg(unix)))]
165163
$item
166164
)*
167165
}
@@ -174,7 +172,6 @@ macro_rules! cfg_windows {
174172
($($item:item)*) => {
175173
$(
176174
#[cfg(any(windows, feature = "docs"))]
177-
#[cfg_attr(feature = "docs", doc(cfg(windows)))]
178175
$item
179176
)*
180177
}

0 commit comments

Comments
 (0)