Deny warnings on CI (#378)

* Deny warnings on CI

* Fix some clippy warnings
yoshuawuyts-patch-1
Taiki Endo 5 years ago committed by GitHub
parent 944e43d4bf
commit 2abf5ca891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,6 +11,8 @@ jobs:
build_and_test: build_and_test:
name: Build and test name: Build and test
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: -Dwarnings
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macOS-latest] os: [ubuntu-latest, windows-latest, macOS-latest]
@ -46,6 +48,8 @@ jobs:
check_fmt_and_docs: check_fmt_and_docs:
name: Checking fmt and docs name: Checking fmt and docs
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
@ -77,6 +81,9 @@ jobs:
clippy_check: clippy_check:
name: Clippy check name: Clippy check
runs-on: ubuntu-latest runs-on: ubuntu-latest
# TODO: There is a lot of warnings
# env:
# RUSTFLAGS: -Dwarnings
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- id: component - id: component

@ -71,7 +71,7 @@ where
} }
if this.timeout.poll(cx).is_ready() { if this.timeout.poll(cx).is_ready() {
let err = Err(io::Error::new(io::ErrorKind::TimedOut, "future timed out").into()); let err = Err(io::Error::new(io::ErrorKind::TimedOut, "future timed out"));
Poll::Ready(err) Poll::Ready(err)
} else { } else {
Poll::Pending Poll::Pending

@ -32,7 +32,7 @@ impl<T: Write + Unpin + ?Sized> Future for WriteFmtFuture<'_, T> {
buffer, buffer,
.. ..
} = &mut *self; } = &mut *self;
let mut buffer = buffer.as_mut().unwrap(); let buffer = buffer.as_mut().unwrap();
// Copy the data from the buffer into the writer until it's done. // Copy the data from the buffer into the writer until it's done.
loop { loop {
@ -40,7 +40,7 @@ impl<T: Write + Unpin + ?Sized> Future for WriteFmtFuture<'_, T> {
futures_core::ready!(Pin::new(&mut **writer).poll_flush(cx))?; futures_core::ready!(Pin::new(&mut **writer).poll_flush(cx))?;
return Poll::Ready(Ok(())); return Poll::Ready(Ok(()));
} }
let i = futures_core::ready!(Pin::new(&mut **writer).poll_write(cx, &mut buffer))?; let i = futures_core::ready!(Pin::new(&mut **writer).poll_write(cx, buffer))?;
if i == 0 { if i == 0 {
return Poll::Ready(Err(io::ErrorKind::WriteZero.into())); return Poll::Ready(Err(io::ErrorKind::WriteZero.into()));
} }

@ -210,7 +210,7 @@ impl ToSocketAddrs for str {
impl Future<Output = Self::Iter>, impl Future<Output = Self::Iter>,
ToSocketAddrsFuture<Self::Iter> ToSocketAddrsFuture<Self::Iter>
) { ) {
if let Some(addr) = self.parse().ok() { if let Ok(addr) = self.parse() {
return ToSocketAddrsFuture::Ready(Ok(vec![addr].into_iter())); return ToSocketAddrsFuture::Ready(Ok(vec![addr].into_iter()));
} }

@ -799,7 +799,7 @@ impl AsRef<Path> for String {
impl AsRef<Path> for std::path::PathBuf { impl AsRef<Path> for std::path::PathBuf {
fn as_ref(&self) -> &Path { fn as_ref(&self) -> &Path {
Path::new(self.into()) Path::new(self)
} }
} }

@ -5,7 +5,7 @@ use crate::path::Path;
/// This struct is an async version of [`std::path::PathBuf`]. /// This struct is an async version of [`std::path::PathBuf`].
/// ///
/// [`std::path::Path`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html /// [`std::path::Path`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Default)]
pub struct PathBuf { pub struct PathBuf {
inner: std::path::PathBuf, inner: std::path::PathBuf,
} }
@ -206,7 +206,7 @@ impl From<std::path::PathBuf> for PathBuf {
impl Into<std::path::PathBuf> for PathBuf { impl Into<std::path::PathBuf> for PathBuf {
fn into(self) -> std::path::PathBuf { fn into(self) -> std::path::PathBuf {
self.inner.into() self.inner
} }
} }

@ -59,7 +59,7 @@ pub use crate::stream::Stream;
/// # } /// # }
/// # } /// # }
/// # } /// # }
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// impl ExactSizeStream for Counter { /// impl ExactSizeStream for Counter {
/// // We can easily calculate the remaining number of iterations. /// // We can easily calculate the remaining number of iterations.
@ -74,7 +74,6 @@ pub use crate::stream::Stream;
/// ///
/// assert_eq!(5, counter.len()); /// assert_eq!(5, counter.len());
/// # }); /// # });
/// # }
/// ``` /// ```
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]

@ -14,7 +14,7 @@ use crate::stream::IntoStream;
/// ## Examples /// ## Examples
/// ///
/// ``` /// ```
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// use async_std::prelude::*; /// use async_std::prelude::*;
/// use async_std::stream::{self, Extend}; /// use async_std::stream::{self, Extend};
@ -25,7 +25,7 @@ use crate::stream::IntoStream;
/// ///
/// assert_eq!(v, vec![1, 2, 3, 3, 3]); /// assert_eq!(v, vec![1, 2, 3, 3, 3]);
/// # /// #
/// # }) } /// # })
/// ``` /// ```
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]

@ -30,7 +30,7 @@ pin_project! {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// use async_std::prelude::*; /// use async_std::prelude::*;
/// use async_std::sync::Mutex; /// use async_std::sync::Mutex;
@ -58,8 +58,7 @@ pin_project! {
/// assert_eq!(s.next().await, Some(3)); /// assert_eq!(s.next().await, Some(3));
/// assert_eq!(s.next().await, None); /// assert_eq!(s.next().await, None);
/// # /// #
/// # }) } /// # })
///
/// ``` /// ```
pub fn from_fn<T, F, Fut>(f: F) -> FromFn<F, Fut, T> pub fn from_fn<T, F, Fut>(f: F) -> FromFn<F, Fut, T>
where where

@ -29,7 +29,7 @@ pin_project! {
/// Basic usage: /// Basic usage:
/// ///
/// ``` /// ```
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// use async_std::prelude::*; /// use async_std::prelude::*;
/// use async_std::stream; /// use async_std::stream;
@ -42,13 +42,13 @@ pin_project! {
/// assert_eq!(s.next().await, Some(1)); /// assert_eq!(s.next().await, Some(1));
/// assert_eq!(s.next().await, Some(1)); /// assert_eq!(s.next().await, Some(1));
/// assert_eq!(s.next().await, Some(1)); /// assert_eq!(s.next().await, Some(1));
/// # }) } /// # })
/// ``` /// ```
/// ///
/// Going finite: /// Going finite:
/// ///
/// ``` /// ```
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// use async_std::prelude::*; /// use async_std::prelude::*;
/// use async_std::stream; /// use async_std::stream;
@ -60,7 +60,7 @@ pin_project! {
/// assert_eq!(s.next().await, Some(1)); /// assert_eq!(s.next().await, Some(1));
/// assert_eq!(s.next().await, Some(1)); /// assert_eq!(s.next().await, Some(1));
/// assert_eq!(s.next().await, None); /// assert_eq!(s.next().await, None);
/// # }) } /// # })
/// ``` /// ```
pub fn repeat_with<F, Fut, A>(repeater: F) -> RepeatWith<F, Fut, A> pub fn repeat_with<F, Fut, A>(repeater: F) -> RepeatWith<F, Fut, A>
where where

@ -8,7 +8,7 @@ use crate::sync::Mutex;
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// use async_std::sync::{Arc, Barrier}; /// use async_std::sync::{Arc, Barrier};
/// use async_std::task; /// use async_std::task;
@ -30,7 +30,6 @@ use crate::sync::Mutex;
/// handle.await; /// handle.await;
/// } /// }
/// # }); /// # });
/// # }
/// ``` /// ```
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
@ -120,7 +119,7 @@ impl Barrier {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// use async_std::sync::{Arc, Barrier}; /// use async_std::sync::{Arc, Barrier};
/// use async_std::task; /// use async_std::task;
@ -142,7 +141,6 @@ impl Barrier {
/// handle.await; /// handle.await;
/// } /// }
/// # }); /// # });
/// # }
/// ``` /// ```
pub async fn wait(&self) -> BarrierWaitResult { pub async fn wait(&self) -> BarrierWaitResult {
let mut lock = self.state.lock().await; let mut lock = self.state.lock().await;
@ -190,7 +188,7 @@ impl BarrierWaitResult {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// use async_std::sync::Barrier; /// use async_std::sync::Barrier;
/// ///
@ -198,7 +196,6 @@ impl BarrierWaitResult {
/// let barrier_wait_result = barrier.wait().await; /// let barrier_wait_result = barrier.wait().await;
/// println!("{:?}", barrier_wait_result.is_leader()); /// println!("{:?}", barrier_wait_result.is_leader());
/// # }); /// # });
/// # }
/// ``` /// ```
pub fn is_leader(&self) -> bool { pub fn is_leader(&self) -> bool {
self.0 self.0

@ -18,13 +18,13 @@ use std::pin::Pin;
/// Basic usage: /// Basic usage:
/// ///
/// ``` /// ```
/// # fn main() { async_std::task::block_on(async { /// # async_std::task::block_on(async {
/// # /// #
/// use async_std::task; /// use async_std::task;
/// ///
/// task::yield_now().await; /// task::yield_now().await;
/// # /// #
/// # }) } /// # })
/// ``` /// ```
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]

Loading…
Cancel
Save