Skip to content

Commit 3f56183

Browse files
committed
Fix build and lint errors on MSRV and Stable
1 parent 26abc13 commit 3f56183

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/error.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ impl From<VfsErrorKind> for VfsError {
2626
let kind = match kind {
2727
VfsErrorKind::IoError(io) => match io.kind() {
2828
io::ErrorKind::NotFound => VfsErrorKind::FileNotFound,
29-
io::ErrorKind::Unsupported => VfsErrorKind::NotSupported,
29+
// TODO: If MSRV changes to 1.53, enable this. Alternatively,
30+
// if it's possible to #[cfg] just this line, try that
31+
// io::ErrorKind::Unsupported => VfsErrorKind::NotSupported,
3032
_ => VfsErrorKind::IoError(io),
3133
},
3234
// Remaining kinda are passed through as-is

src/filesystem.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ pub trait FileSystem: Debug + Sync + Send + 'static {
3535
/// Removes the directory at this path
3636
fn remove_dir(&self, path: &str) -> VfsResult<()>;
3737
/// Copies the src path to the destination path within the same filesystem (optional)
38-
fn copy_file(&self, _src: &str, dest: &str) -> VfsResult<()> {
38+
fn copy_file(&self, _src: &str, _dest: &str) -> VfsResult<()> {
3939
Err(VfsErrorKind::NotSupported.into())
4040
}
4141
/// Moves the src path to the destination path within the same filesystem (optional)
42-
fn move_file(&self, _src: &str, dest: &str) -> VfsResult<()> {
42+
fn move_file(&self, _src: &str, _dest: &str) -> VfsResult<()> {
4343
Err(VfsErrorKind::NotSupported.into())
4444
}
4545
/// Moves the src directory to the destination path within the same filesystem (optional)
46-
fn move_dir(&self, _src: &str, dest: &str) -> VfsResult<()> {
46+
fn move_dir(&self, _src: &str, _dest: &str) -> VfsResult<()> {
4747
Err(VfsErrorKind::NotSupported.into())
4848
}
4949
}

src/impls/memory.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl FileSystem for MemoryFS {
162162
fn open_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndRead>> {
163163
let handle = self.handle.read().unwrap();
164164
let file = handle.files.get(path).ok_or(VfsErrorKind::FileNotFound)?;
165-
ensure_file(path, file)?;
165+
ensure_file(file)?;
166166
Ok(Box::new(ReadableFile {
167167
content: file.content.clone(),
168168
position: 0,
@@ -356,7 +356,7 @@ mod tests {
356356
}
357357
}
358358

359-
fn ensure_file(path: &str, file: &MemoryFile) -> VfsResult<()> {
359+
fn ensure_file(file: &MemoryFile) -> VfsResult<()> {
360360
if file.file_type != VfsFileType::File {
361361
return Err(VfsErrorKind::Other("Not a file".into()).into());
362362
}

src/path.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,12 @@ impl VfsPath {
673673
if Arc::ptr_eq(&self.fs, &destination.fs) {
674674
let result = self.fs.fs.copy_file(&self.path, &destination.path);
675675
match result {
676-
Err(err) if matches!(err.kind(), VfsErrorKind::NotSupported) => {
677-
// continue
678-
}
676+
Err(err) => match err.kind() {
677+
VfsErrorKind::NotSupported => {
678+
// continue
679+
}
680+
_ => return Err(err),
681+
},
679682
other => return other,
680683
}
681684
}
@@ -729,9 +732,12 @@ impl VfsPath {
729732
if Arc::ptr_eq(&self.fs, &destination.fs) {
730733
let result = self.fs.fs.move_file(&self.path, &destination.path);
731734
match result {
732-
Err(err) if matches!(err.kind(), VfsErrorKind::NotSupported) => {
733-
// continue
734-
}
735+
Err(err) => match err.kind() {
736+
VfsErrorKind::NotSupported => {
737+
// continue
738+
}
739+
_ => return Err(err),
740+
},
735741
other => return other,
736742
}
737743
}
@@ -840,9 +846,12 @@ impl VfsPath {
840846
if Arc::ptr_eq(&self.fs, &destination.fs) {
841847
let result = self.fs.fs.move_dir(&self.path, &destination.path);
842848
match result {
843-
Err(err) if matches!(err.kind(), VfsErrorKind::NotSupported) => {
844-
// continue
845-
}
849+
Err(err) => match err.kind() {
850+
VfsErrorKind::NotSupported => {
851+
// continue
852+
}
853+
_ => return Err(err),
854+
},
846855
other => return other,
847856
}
848857
}

0 commit comments

Comments
 (0)