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

Re-export raw::Crate in rls_analysis #1508

Merged
merged 3 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rls-analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions rls-analysis/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions rls-analysis/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ 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;
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,
Expand Down
18 changes: 12 additions & 6 deletions rls-vfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ impl fmt::Display for Error {
}
}

impl<U> Default for Vfs<U> {
fn default() -> Self {
Self::new()
}
}

impl<U> Vfs<U> {
/// Creates a new, empty VFS.
pub fn new() -> Vfs<U> {
Expand Down Expand Up @@ -558,7 +564,7 @@ impl<T: FileLoader, U> VfsInternal<T, U> {
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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -823,7 +829,7 @@ fn byte_in_str(s: &str, c: span::Column<span::ZeroIndexed>) -> Result<usize, Err
}
}

return Err(Error::InternalError("Out of bounds access in `byte_in_str`"));
Err(Error::InternalError("Out of bounds access in `byte_in_str`"))
}

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

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

trait FileLoader {
Expand All @@ -864,7 +870,7 @@ impl FileLoader for RealFileLoader {
}
};
let mut buf = vec![];
if let Err(_) = file.read_to_end(&mut buf) {
if file.read_to_end(&mut buf).is_err() {
return Err(Error::Io(
Some(file_name.to_owned()),
Some(format!("Could not read file: {}", file_name.display())),
Expand Down