diff --git a/rls-analysis/src/lib.rs b/rls-analysis/src/lib.rs index 84663140d66..2bd47328e17 100644 --- a/rls-analysis/src/lib.rs +++ b/rls-analysis/src/lib.rs @@ -21,7 +21,7 @@ mod util; use analysis::Analysis; pub use analysis::{Def, Ref}; pub use loader::{AnalysisLoader, CargoAnalysisLoader, SearchDirectory, Target}; -pub use raw::{name_space_for_def_kind, read_analysis_from_files, CrateId, DefKind}; +pub use raw::{name_space_for_def_kind, read_analysis_from_files, Crate, CrateId, DefKind}; pub use symbol_query::SymbolQuery; use std::collections::HashMap; diff --git a/rls-analysis/src/lowering.rs b/rls-analysis/src/lowering.rs index d69254d5c5b..405c21ad4e0 100644 --- a/rls-analysis/src/lowering.rs +++ b/rls-analysis/src/lowering.rs @@ -2,14 +2,11 @@ //! in-memory representation. use crate::analysis::{Def, Glob, PerCrateAnalysis, Ref}; -use data; use crate::loader::AnalysisLoader; use crate::raw::{self, CrateId, DefKind, RelationKind}; use crate::util; use crate::{AResult, AnalysisHost, Id, Span, NULL}; -use span; - use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; use std::iter::Extend; diff --git a/rls-analysis/src/raw.rs b/rls-analysis/src/raw.rs index 77996fa3907..3b712242f14 100644 --- a/rls-analysis/src/raw.rs +++ b/rls-analysis/src/raw.rs @@ -4,8 +4,6 @@ pub use data::{ CratePreludeData, Def, DefKind, GlobalCrateId as CrateId, Import, Ref, Relation, RelationKind, SigElement, Signature, SpanData, }; -use crate::listings::{DirectoryListing, ListingKind}; -use crate::{AnalysisLoader, Blacklist}; use std::collections::HashMap; use std::fs::File; @@ -13,6 +11,9 @@ use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::time::{Instant, SystemTime}; +use crate::listings::{DirectoryListing, ListingKind}; +use crate::{AnalysisLoader, Blacklist}; + #[derive(Debug)] pub struct Crate { pub id: CrateId, diff --git a/rls-vfs/src/lib.rs b/rls-vfs/src/lib.rs index 8b697ee6ec5..bd73c780f01 100644 --- a/rls-vfs/src/lib.rs +++ b/rls-vfs/src/lib.rs @@ -170,6 +170,12 @@ impl fmt::Display for Error { } } +impl Default for Vfs { + fn default() -> Self { + Self::new() + } +} + impl Vfs { /// Creates a new, empty VFS. pub fn new() -> Vfs { @@ -558,7 +564,7 @@ impl VfsInternal { let mut files = self.files.lock().unwrap(); match files.get_mut(path) { Some(ref mut file) => { - if let None = file.user_data { + if file.user_data.is_none() { let text = match file.kind { FileKind::Text(ref f) => Some(&f.text as &str), FileKind::Binary(_) => None, @@ -587,7 +593,7 @@ fn coalesce_changes<'a>(changes: &'a [Change]) -> HashMap<&'a Path, Vec<&'a Chan // Note that for any given file, we preserve the order of the changes. let mut result = HashMap::new(); for c in changes { - result.entry(&*c.file()).or_insert(vec![]).push(c); + result.entry(&*c.file()).or_insert_with(Vec::new).push(c); } result } @@ -735,7 +741,7 @@ impl TextFile { new_text.push_str(&self.text[range.1 as usize..]); new_text } - Change::AddFile { file: _, ref text } => text.to_owned(), + Change::AddFile { ref text, .. } => text.to_owned(), }; self.text = new_text; @@ -823,7 +829,7 @@ fn byte_in_str(s: &str, c: span::Column) -> Result) -> Result