When I try to install wsld in WSL with cargo install --git https://github.com/nbdd0121/wsld wsld the installation fails with
Compiling tokio-macros v1.1.0
error: unexpected `self` parameter in function
--> <HOME>/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.2.0/src/net/tcp/stream.rs:627:40
|
627 | pub fn try_read_buf<B: BufMut>(&self, buf: &mut B) -> io::Result<usize> {
| ^^^^^ not valid as function parameter
|
= note: `self` is only valid as the first parameter of an associated function
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `#[doc =
r" Try to read data from the stream into the provided buffer, advancing the"]
#[doc = r" buffer's internal cursor, returning how many bytes were read."]
#[doc = r""]
#[doc =
r" Receives any pending data from the socket but does not wait for new data"]
#[doc = r" to arrive. On success, returns the number of bytes read. Because"]
#[doc =
r" `try_read_buf()` is non-blocking, the buffer does not have to be stored by"]
#[doc = r" the async task and can exist entirely on the stack."]
#[doc = r""]
#[doc =
r" Usually, [`readable()`] or [`ready()`] is used with this function."]
#[doc = r""]
#[doc = r" [`readable()`]: TcpStream::readable()"]
#[doc = r" [`ready()`]: TcpStream::ready()"]
#[doc = r""]
#[doc = r" # Return"]
#[doc = r""]
#[doc =
r" If data is successfully read, `Ok(n)` is returned, where `n` is the"]
#[doc =
r" number of bytes read. `Ok(0)` indicates the stream's read half is closed"]
#[doc =
r" and will no longer yield data. If the stream is not ready to read data"]
#[doc = r" `Err(io::ErrorKind::WouldBlock)` is returned."]
#[doc = r""]
#[doc = r" # Examples"]
#[doc = r""]
#[doc = r" ```no_run"]
#[doc = r" use tokio::net::TcpStream;"]
#[doc = r" use std::error::Error;"]
#[doc = r" use std::io;"]
#[doc = r""]
#[doc = r" #[tokio::main]"]
#[doc = r" async fn main() -> Result<(), Box<dyn Error>> {"]
#[doc = r" // Connect to a peer"]
#[doc = r#" let stream = TcpStream::connect("127.0.0.1:8080").await?;"#]
#[doc = r""]
#[doc = r" loop {"]
#[doc = r" // Wait for the socket to be readable"]
#[doc = r" stream.readable().await?;"]
#[doc = r""]
#[doc = r" let mut buf = Vec::with_capacity(4096);"]
#[doc = r""]
#[doc =
r" // Try to read data, this may still fail with `WouldBlock`"]
#[doc = r" // if the readiness event is a false positive."]
#[doc = r" match stream.try_read_buf(&mut buf) {"]
#[doc = r" Ok(0) => break,"]
#[doc = r" Ok(n) => {"]
#[doc = r#" println!("read {} bytes", n);"#]
#[doc = r" }"]
#[doc =
r" Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {"]
#[doc = r" continue;"]
#[doc = r" }"]
#[doc = r" Err(e) => {"]
#[doc = r" return Err(e.into());"]
#[doc = r" }"]
#[doc = r" }"]
#[doc = r" }"]
#[doc = r""]
#[doc = r" Ok(())"]
#[doc = r" }"]
#[doc = r" ```"]
pub fn try_read_buf<B: BufMut>(self: (/*ERROR*/), buf: &mut B)
-> io::Result<usize> {
self.io.registration().try_io(Interest::READABLE,
||
{
use std::io::Read;
let dst = buf.chunk_mut();
let dst =
unsafe {
&mut *(dst as *mut _ as
*mut [std::mem::MaybeUninit<u8>]
as *mut [u8])
};
let n = (&*self.io).read(dst)?;
unsafe { buf.advance_mut(n); }
Ok(n)
})
}`
--> <HOME>/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.2.0/src/macros/cfg.rs:132:13
|
131 | #[cfg_attr(docsrs, doc(cfg(feature = "io-util")))]
| - expected one of 9 possible tokens
132 | $item
| ^^^^^ unexpected token
|
::: <HOME>/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.2.0/src/net/tcp/stream.rs:569:5
|
569 | / cfg_io_util! {
570 | | /// Try to read data from the stream into the provided buffer, advancing the
571 | | /// buffer's internal cursor, returning how many bytes were read.
572 | | ///
... |
645 | | }
646 | | }
| |_____- in this macro invocation
error: aborting due to 2 previous errors
When I try to install wsld in WSL with
cargo install --git https://github.com/nbdd0121/wsld wsld
the installation fails withThe prebuilt binaries work fine, however.
Thanks for the awesome work!