Skip to content

Commit

Permalink
libstd: deny(elided_lifetimes_in_paths), fixes in wasi
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Mar 31, 2019
1 parent 1852389 commit 13a4ac3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions src/libstd/sys/wasi/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ pub type RiFlags = u16;
pub type RoFlags = u16;
pub type SiFlags = u16;

fn iovec(a: &mut [IoVecMut]) -> (*const libc::__wasi_iovec_t, usize) {
fn iovec(a: &mut [IoVecMut<'_>]) -> (*const libc::__wasi_iovec_t, usize) {
assert_eq!(
mem::size_of::<IoVecMut>(),
mem::size_of::<IoVecMut<'_>>(),
mem::size_of::<libc::__wasi_iovec_t>()
);
assert_eq!(
mem::align_of::<IoVecMut>(),
mem::align_of::<IoVecMut<'_>>(),
mem::align_of::<libc::__wasi_iovec_t>()
);
(a.as_ptr() as *const libc::__wasi_iovec_t, a.len())
}

fn ciovec(a: &[IoVec]) -> (*const libc::__wasi_ciovec_t, usize) {
fn ciovec(a: &[IoVec<'_>]) -> (*const libc::__wasi_ciovec_t, usize) {
assert_eq!(
mem::size_of::<IoVec>(),
mem::size_of::<IoVec<'_>>(),
mem::size_of::<libc::__wasi_ciovec_t>()
);
assert_eq!(
mem::align_of::<IoVec>(),
mem::align_of::<IoVec<'_>>(),
mem::align_of::<libc::__wasi_ciovec_t>()
);
(a.as_ptr() as *const libc::__wasi_ciovec_t, a.len())
Expand All @@ -56,28 +56,28 @@ impl WasiFd {
cvt_wasi(unsafe { libc::__wasi_fd_datasync(self.fd) })
}

pub fn pread(&self, bufs: &mut [IoVecMut], offset: u64) -> io::Result<usize> {
pub fn pread(&self, bufs: &mut [IoVecMut<'_>], offset: u64) -> io::Result<usize> {
let mut read = 0;
let (ptr, len) = iovec(bufs);
cvt_wasi(unsafe { libc::__wasi_fd_pread(self.fd, ptr, len, offset, &mut read) })?;
Ok(read)
}

pub fn pwrite(&self, bufs: &[IoVec], offset: u64) -> io::Result<usize> {
pub fn pwrite(&self, bufs: &[IoVec<'_>], offset: u64) -> io::Result<usize> {
let mut read = 0;
let (ptr, len) = ciovec(bufs);
cvt_wasi(unsafe { libc::__wasi_fd_pwrite(self.fd, ptr, len, offset, &mut read) })?;
Ok(read)
}

pub fn read(&self, bufs: &mut [IoVecMut]) -> io::Result<usize> {
pub fn read(&self, bufs: &mut [IoVecMut<'_>]) -> io::Result<usize> {
let mut read = 0;
let (ptr, len) = iovec(bufs);
cvt_wasi(unsafe { libc::__wasi_fd_read(self.fd, ptr, len, &mut read) })?;
Ok(read)
}

pub fn write(&self, bufs: &[IoVec]) -> io::Result<usize> {
pub fn write(&self, bufs: &[IoVec<'_>]) -> io::Result<usize> {
let mut read = 0;
let (ptr, len) = ciovec(bufs);
cvt_wasi(unsafe { libc::__wasi_fd_write(self.fd, ptr, len, &mut read) })?;
Expand Down Expand Up @@ -281,7 +281,7 @@ impl WasiFd {

pub fn sock_recv(
&self,
ri_data: &mut [IoVecMut],
ri_data: &mut [IoVecMut<'_>],
ri_flags: RiFlags,
) -> io::Result<(usize, RoFlags)> {
let mut ro_datalen = 0;
Expand All @@ -293,7 +293,7 @@ impl WasiFd {
Ok((ro_datalen, ro_flags))
}

pub fn sock_send(&self, si_data: &[IoVec], si_flags: SiFlags) -> io::Result<usize> {
pub fn sock_send(&self, si_data: &[IoVec<'_>], si_flags: SiFlags) -> io::Result<usize> {
let mut so_datalen = 0;
let (ptr, len) = ciovec(si_data);
cvt_wasi(unsafe { libc::__wasi_sock_send(self.fd, ptr, len, si_flags, &mut so_datalen) })?;
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/sys/wasi/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Eq for FilePermissions {
}

impl fmt::Debug for FilePermissions {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}
Expand Down Expand Up @@ -125,13 +125,13 @@ impl Hash for FileType {
}

impl fmt::Debug for FileType {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}

impl fmt::Debug for ReadDir {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}
Expand Down Expand Up @@ -236,7 +236,7 @@ impl DirBuilder {
}

impl fmt::Debug for File {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sys/wasi/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl TcpStream {
}

impl fmt::Debug for TcpStream {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ impl TcpListener {
}

impl fmt::Debug for TcpListener {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}
Expand Down Expand Up @@ -282,7 +282,7 @@ impl UdpSocket {
}

impl fmt::Debug for UdpSocket {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/wasi/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> {

pub struct SplitPaths<'a>(&'a Void);

pub fn split_paths(_unparsed: &OsStr) -> SplitPaths {
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
panic!("unsupported")
}

Expand All @@ -62,7 +62,7 @@ pub fn join_paths<I, T>(_paths: I) -> Result<OsString, JoinPathsError>
}

impl fmt::Display for JoinPathsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"not supported on wasm yet".fmt(f)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/wasi/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn is_verbatim_sep(b: u8) -> bool {
b == b'/'
}

pub fn parse_prefix(_: &OsStr) -> Option<Prefix> {
pub fn parse_prefix(_: &OsStr) -> Option<Prefix<'_>> {
None
}

Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sys/wasi/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl From<File> for Stdio {
}

impl fmt::Debug for Command {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
Ok(())
}
}
Expand Down Expand Up @@ -108,13 +108,13 @@ impl Eq for ExitStatus {
}

impl fmt::Debug for ExitStatus {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}

impl fmt::Display for ExitStatus {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
}
}
Expand Down

0 comments on commit 13a4ac3

Please sign in to comment.