Skip to content

Commit 33b4750

Browse files
marmistrzabrown
authored andcommitted
Fix unnecessary structure name repetitions, as reported by clippy
1 parent 3f8fb37 commit 33b4750

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

crates/wasi-common/src/entry.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,43 @@ pub(crate) enum Descriptor {
1818

1919
impl From<OsHandle> for Descriptor {
2020
fn from(handle: OsHandle) -> Self {
21-
Descriptor::OsHandle(handle)
21+
Self::OsHandle(handle)
2222
}
2323
}
2424

2525
impl From<Box<dyn VirtualFile>> for Descriptor {
2626
fn from(virt: Box<dyn VirtualFile>) -> Self {
27-
Descriptor::VirtualFile(virt)
27+
Self::VirtualFile(virt)
2828
}
2929
}
3030

3131
impl fmt::Debug for Descriptor {
3232
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3333
match self {
34-
Descriptor::OsHandle(handle) => write!(f, "{:?}", handle),
35-
Descriptor::VirtualFile(_) => write!(f, "VirtualFile"),
36-
Descriptor::Stdin => write!(f, "Stdin"),
37-
Descriptor::Stdout => write!(f, "Stdout"),
38-
Descriptor::Stderr => write!(f, "Stderr"),
34+
Self::OsHandle(handle) => write!(f, "{:?}", handle),
35+
Self::VirtualFile(_) => write!(f, "VirtualFile"),
36+
Self::Stdin => write!(f, "Stdin"),
37+
Self::Stdout => write!(f, "Stdout"),
38+
Self::Stderr => write!(f, "Stderr"),
3939
}
4040
}
4141
}
4242

4343
impl Descriptor {
44-
pub(crate) fn try_clone(&self) -> io::Result<Descriptor> {
44+
pub(crate) fn try_clone(&self) -> io::Result<Self> {
4545
match self {
46-
Descriptor::OsHandle(file) => file.try_clone().map(|f| OsHandle::from(f).into()),
47-
Descriptor::VirtualFile(virt) => virt.try_clone().map(Descriptor::VirtualFile),
48-
Descriptor::Stdin => Ok(Descriptor::Stdin),
49-
Descriptor::Stdout => Ok(Descriptor::Stdout),
50-
Descriptor::Stderr => Ok(Descriptor::Stderr),
46+
Self::OsHandle(file) => file.try_clone().map(|f| OsHandle::from(f).into()),
47+
Self::VirtualFile(virt) => virt.try_clone().map(Self::VirtualFile),
48+
Self::Stdin => Ok(Self::Stdin),
49+
Self::Stdout => Ok(Self::Stdout),
50+
Self::Stderr => Ok(Self::Stderr),
5151
}
5252
}
5353

5454
/// Return a reference to the `OsHandle` or `VirtualFile` treating it as an
5555
/// actual file/dir, and allowing operations which require an actual file and
5656
/// not just a stream or socket file descriptor.
57-
pub(crate) fn as_file<'descriptor>(&'descriptor self) -> WasiResult<&'descriptor Descriptor> {
57+
pub(crate) fn as_file<'descriptor>(&'descriptor self) -> WasiResult<&'descriptor Self> {
5858
match self {
5959
Self::OsHandle(_) => Ok(self),
6060
Self::VirtualFile(_) => Ok(self),
@@ -65,7 +65,7 @@ impl Descriptor {
6565
/// Like `as_file`, but return a mutable reference.
6666
pub(crate) fn as_file_mut<'descriptor>(
6767
&'descriptor mut self,
68-
) -> WasiResult<&'descriptor mut Descriptor> {
68+
) -> WasiResult<&'descriptor mut Self> {
6969
match self {
7070
Self::OsHandle(_) => Ok(self),
7171
Self::VirtualFile(_) => Ok(self),

crates/wasi-common/src/virtfs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum VirtualDirEntry {
2020

2121
impl VirtualDirEntry {
2222
pub fn empty_directory() -> Self {
23-
VirtualDirEntry::Directory(HashMap::new())
23+
Self::Directory(HashMap::new())
2424
}
2525
}
2626

@@ -313,7 +313,7 @@ impl VirtualFile for InMemoryFile {
313313
}
314314

315315
fn try_clone(&self) -> io::Result<Box<dyn VirtualFile>> {
316-
Ok(Box::new(InMemoryFile {
316+
Ok(Box::new(Self {
317317
cursor: 0,
318318
fd_flags: self.fd_flags,
319319
parent: Rc::clone(&self.parent),
@@ -550,21 +550,21 @@ pub struct VirtualDir {
550550

551551
impl VirtualDir {
552552
pub fn new(writable: bool) -> Self {
553-
VirtualDir {
553+
Self {
554554
writable,
555555
parent: Rc::new(RefCell::new(None)),
556556
entries: Rc::new(RefCell::new(HashMap::new())),
557557
}
558558
}
559559

560560
#[allow(dead_code)]
561-
pub fn with_dir<P: AsRef<Path>>(mut self, dir: VirtualDir, path: P) -> Self {
561+
pub fn with_dir<P: AsRef<Path>>(mut self, dir: Self, path: P) -> Self {
562562
self.add_dir(dir, path);
563563
self
564564
}
565565

566566
#[allow(dead_code)]
567-
pub fn add_dir<P: AsRef<Path>>(&mut self, dir: VirtualDir, path: P) {
567+
pub fn add_dir<P: AsRef<Path>>(&mut self, dir: Self, path: P) {
568568
let entry = Box::new(dir);
569569
entry.set_parent(Some(self.try_clone().expect("can clone self")));
570570
self.entries
@@ -603,7 +603,7 @@ const RESERVED_ENTRY_COUNT: u32 = 2;
603603

604604
impl VirtualFile for VirtualDir {
605605
fn try_clone(&self) -> io::Result<Box<dyn VirtualFile>> {
606-
Ok(Box::new(VirtualDir {
606+
Ok(Box::new(Self {
607607
writable: self.writable,
608608
parent: Rc::clone(&self.parent),
609609
entries: Rc::clone(&self.entries),
@@ -773,7 +773,7 @@ impl VirtualFile for VirtualDir {
773773
Entry::Occupied(_) => Err(WasiError::EEXIST),
774774
Entry::Vacant(v) => {
775775
if self.writable {
776-
let new_dir = Box::new(VirtualDir::new(true));
776+
let new_dir = Box::new(Self::new(true));
777777
new_dir.set_parent(Some(self.try_clone()?));
778778
v.insert(new_dir);
779779
Ok(())

0 commit comments

Comments
 (0)