mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
chore: fix newly added warnings (#4253)
This commit is contained in:
@@ -267,8 +267,6 @@ jobs:
|
|||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- name: Install rustfmt
|
|
||||||
run: rustup component add rustfmt
|
|
||||||
|
|
||||||
# Check fmt
|
# Check fmt
|
||||||
- name: "rustfmt --check"
|
- name: "rustfmt --check"
|
||||||
@@ -285,7 +283,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
run: rustup update 1.52.1 && rustup default 1.52.1
|
run: rustup update 1.56 && rustup default 1.56
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- name: Install clippy
|
- name: Install clippy
|
||||||
run: rustup component add clippy
|
run: rustup component add clippy
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ fn rt() -> tokio::runtime::Runtime {
|
|||||||
const BLOCK_COUNT: usize = 1_000;
|
const BLOCK_COUNT: usize = 1_000;
|
||||||
|
|
||||||
const BUFFER_SIZE: usize = 4096;
|
const BUFFER_SIZE: usize = 4096;
|
||||||
const DEV_ZERO: &'static str = "/dev/zero";
|
const DEV_ZERO: &str = "/dev/zero";
|
||||||
|
|
||||||
fn async_read_codec(b: &mut Bencher) {
|
fn async_read_codec(b: &mut Bencher) {
|
||||||
let rt = rt();
|
let rt = rt();
|
||||||
|
|||||||
+1
-1
@@ -149,7 +149,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_request(line: &str, db: &Arc<Database>) -> Response {
|
fn handle_request(line: &str, db: &Arc<Database>) -> Response {
|
||||||
let request = match Request::parse(&line) {
|
let request = match Request::parse(line) {
|
||||||
Ok(req) => req,
|
Ok(req) => req,
|
||||||
Err(e) => return Response::Error { msg: e },
|
Err(e) => return Response::Error { msg: e },
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,17 +66,17 @@ where
|
|||||||
use Poll::Ready;
|
use Poll::Ready;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut me = self.as_mut().project();
|
let me = self.as_mut().project();
|
||||||
|
|
||||||
let item = match ready!(me.stream.poll_next(cx)) {
|
let item = match ready!(me.stream.poll_next(cx)) {
|
||||||
Some(item) => item,
|
Some(item) => item,
|
||||||
None => {
|
None => {
|
||||||
return Ready(U::finalize(sealed::Internal, &mut me.collection));
|
return Ready(U::finalize(sealed::Internal, me.collection));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !U::extend(sealed::Internal, &mut me.collection, item) {
|
if !U::extend(sealed::Internal, me.collection, item) {
|
||||||
return Ready(U::finalize(sealed::Internal, &mut me.collection));
|
return Ready(U::finalize(sealed::Internal, me.collection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -598,7 +598,7 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyMutGuard<'a, Inner> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
f: impl FnOnce(&mut AsyncFd<Inner>) -> io::Result<R>,
|
f: impl FnOnce(&mut AsyncFd<Inner>) -> io::Result<R>,
|
||||||
) -> Result<io::Result<R>, TryIoError> {
|
) -> Result<io::Result<R>, TryIoError> {
|
||||||
let result = f(&mut self.async_fd);
|
let result = f(self.async_fd);
|
||||||
|
|
||||||
if let Err(e) = result.as_ref() {
|
if let Err(e) = result.as_ref() {
|
||||||
if e.kind() == io::ErrorKind::WouldBlock {
|
if e.kind() == io::ErrorKind::WouldBlock {
|
||||||
|
|||||||
@@ -204,7 +204,6 @@ impl<R: AsyncRead + AsyncSeek> AsyncSeek for BufReader<R> {
|
|||||||
self.as_mut()
|
self.as_mut()
|
||||||
.get_pin_mut()
|
.get_pin_mut()
|
||||||
.start_seek(SeekFrom::Current(offset))?;
|
.start_seek(SeekFrom::Current(offset))?;
|
||||||
self.as_mut().get_pin_mut().poll_complete(cx)?
|
|
||||||
} else {
|
} else {
|
||||||
// seek backwards by our remainder, and then by the offset
|
// seek backwards by our remainder, and then by the offset
|
||||||
self.as_mut()
|
self.as_mut()
|
||||||
@@ -221,8 +220,8 @@ impl<R: AsyncRead + AsyncSeek> AsyncSeek for BufReader<R> {
|
|||||||
self.as_mut()
|
self.as_mut()
|
||||||
.get_pin_mut()
|
.get_pin_mut()
|
||||||
.start_seek(SeekFrom::Current(n))?;
|
.start_seek(SeekFrom::Current(n))?;
|
||||||
self.as_mut().get_pin_mut().poll_complete(cx)?
|
|
||||||
}
|
}
|
||||||
|
self.as_mut().get_pin_mut().poll_complete(cx)?
|
||||||
}
|
}
|
||||||
SeekState::PendingOverflowed(n) => {
|
SeekState::PendingOverflowed(n) => {
|
||||||
if self.as_mut().get_pin_mut().poll_complete(cx)?.is_pending() {
|
if self.as_mut().get_pin_mut().poll_complete(cx)?.is_pending() {
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ where
|
|||||||
type Output = io::Result<usize>;
|
type Output = io::Result<usize>;
|
||||||
|
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<usize>> {
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<usize>> {
|
||||||
let mut me = self.project();
|
let me = self.project();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// if our buffer is empty, then we need to read some data to continue.
|
// if our buffer is empty, then we need to read some data to continue.
|
||||||
let rem = me.buf.remaining();
|
let rem = me.buf.remaining();
|
||||||
if rem != 0 {
|
if rem != 0 {
|
||||||
ready!(Pin::new(&mut *me.reader).poll_read(cx, &mut me.buf))?;
|
ready!(Pin::new(&mut *me.reader).poll_read(cx, me.buf))?;
|
||||||
if me.buf.remaining() == rem {
|
if me.buf.remaining() == rem {
|
||||||
return Err(eof()).into();
|
return Err(eof()).into();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,14 +258,14 @@ impl<T: 'static, F> TaskLocalFuture<T, F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut project = self.project();
|
let project = self.project();
|
||||||
let val = project.slot.take();
|
let val = project.slot.take();
|
||||||
|
|
||||||
let prev = project.local.inner.with(|c| c.replace(val));
|
let prev = project.local.inner.with(|c| c.replace(val));
|
||||||
|
|
||||||
let _guard = Guard {
|
let _guard = Guard {
|
||||||
prev,
|
prev,
|
||||||
slot: &mut project.slot,
|
slot: project.slot,
|
||||||
local: *project.local,
|
local: *project.local,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ use std::task::{Context, Poll};
|
|||||||
/// which order the runtime polls your tasks in.
|
/// which order the runtime polls your tasks in.
|
||||||
///
|
///
|
||||||
/// [`tokio::select!`]: macro@crate::select
|
/// [`tokio::select!`]: macro@crate::select
|
||||||
#[must_use = "yield_now does nothing unless polled/`await`-ed"]
|
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "rt")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "rt")))]
|
||||||
pub async fn yield_now() {
|
pub async fn yield_now() {
|
||||||
/// Yield implementation
|
/// Yield implementation
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ impl Level {
|
|||||||
// However, that is only supported for arrays of size
|
// However, that is only supported for arrays of size
|
||||||
// 32 or fewer. So in our case we have to explicitly
|
// 32 or fewer. So in our case we have to explicitly
|
||||||
// invoke the constructor for each array element.
|
// invoke the constructor for each array element.
|
||||||
let ctor = || EntryList::default();
|
let ctor = EntryList::default;
|
||||||
|
|
||||||
Level {
|
Level {
|
||||||
level,
|
level,
|
||||||
|
|||||||
Reference in New Issue
Block a user