Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 8f2b9d3

Browse files
committed
Fix Clippy lints in rls-vfs
1 parent b88d5b4 commit 8f2b9d3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

rls-vfs/src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ impl fmt::Display for Error {
170170
}
171171
}
172172

173+
impl<U> Default for Vfs<U> {
174+
fn default() -> Self {
175+
Self::new()
176+
}
177+
}
178+
173179
impl<U> Vfs<U> {
174180
/// Creates a new, empty VFS.
175181
pub fn new() -> Vfs<U> {
@@ -558,7 +564,7 @@ impl<T: FileLoader, U> VfsInternal<T, U> {
558564
let mut files = self.files.lock().unwrap();
559565
match files.get_mut(path) {
560566
Some(ref mut file) => {
561-
if let None = file.user_data {
567+
if file.user_data.is_none() {
562568
let text = match file.kind {
563569
FileKind::Text(ref f) => Some(&f.text as &str),
564570
FileKind::Binary(_) => None,
@@ -587,7 +593,7 @@ fn coalesce_changes<'a>(changes: &'a [Change]) -> HashMap<&'a Path, Vec<&'a Chan
587593
// Note that for any given file, we preserve the order of the changes.
588594
let mut result = HashMap::new();
589595
for c in changes {
590-
result.entry(&*c.file()).or_insert(vec![]).push(c);
596+
result.entry(&*c.file()).or_insert_with(Vec::new).push(c);
591597
}
592598
result
593599
}
@@ -735,7 +741,7 @@ impl TextFile {
735741
new_text.push_str(&self.text[range.1 as usize..]);
736742
new_text
737743
}
738-
Change::AddFile { file: _, ref text } => text.to_owned(),
744+
Change::AddFile { ref text, .. } => text.to_owned(),
739745
};
740746

741747
self.text = new_text;
@@ -823,7 +829,7 @@ fn byte_in_str(s: &str, c: span::Column<span::ZeroIndexed>) -> Result<usize, Err
823829
}
824830
}
825831

826-
return Err(Error::InternalError("Out of bounds access in `byte_in_str`"));
832+
Err(Error::InternalError("Out of bounds access in `byte_in_str`"))
827833
}
828834

829835
/// Return a UTF-8 byte offset in `s` for a given UTF-16 code unit offset.
@@ -842,7 +848,7 @@ fn byte_in_str_utf16(s: &str, c: span::Column<span::ZeroIndexed>) -> Result<usiz
842848
utf16_offset += chr.len_utf16();
843849
}
844850

845-
return Err(Error::InternalError("UTF-16 code unit offset is not at `str` char boundary"));
851+
Err(Error::InternalError("UTF-16 code unit offset is not at `str` char boundary"))
846852
}
847853

848854
trait FileLoader {
@@ -864,7 +870,7 @@ impl FileLoader for RealFileLoader {
864870
}
865871
};
866872
let mut buf = vec![];
867-
if let Err(_) = file.read_to_end(&mut buf) {
873+
if file.read_to_end(&mut buf).is_err() {
868874
return Err(Error::Io(
869875
Some(file_name.to_owned()),
870876
Some(format!("Could not read file: {}", file_name.display())),

0 commit comments

Comments
 (0)