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

Commit d099747

Browse files
authored
Merge pull request #1508 from Xanewok/reexport-raw-crate
Re-export raw::Crate in rls_analysis
2 parents da01448 + e4043eb commit d099747

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

rls-analysis/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod util;
2121
use analysis::Analysis;
2222
pub use analysis::{Def, Ref};
2323
pub use loader::{AnalysisLoader, CargoAnalysisLoader, SearchDirectory, Target};
24-
pub use raw::{name_space_for_def_kind, read_analysis_from_files, CrateId, DefKind};
24+
pub use raw::{name_space_for_def_kind, read_analysis_from_files, Crate, CrateId, DefKind};
2525
pub use symbol_query::SymbolQuery;
2626

2727
use std::collections::HashMap;

rls-analysis/src/lowering.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
//! in-memory representation.
33
44
use crate::analysis::{Def, Glob, PerCrateAnalysis, Ref};
5-
use data;
65
use crate::loader::AnalysisLoader;
76
use crate::raw::{self, CrateId, DefKind, RelationKind};
87
use crate::util;
98
use crate::{AResult, AnalysisHost, Id, Span, NULL};
109

11-
use span;
12-
1310
use std::collections::hash_map::Entry;
1411
use std::collections::{HashMap, HashSet};
1512
use std::iter::Extend;

rls-analysis/src/raw.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ pub use data::{
44
CratePreludeData, Def, DefKind, GlobalCrateId as CrateId, Import, Ref, Relation, RelationKind,
55
SigElement, Signature, SpanData,
66
};
7-
use crate::listings::{DirectoryListing, ListingKind};
8-
use crate::{AnalysisLoader, Blacklist};
97

108
use std::collections::HashMap;
119
use std::fs::File;
1210
use std::io::{self, Read};
1311
use std::path::{Path, PathBuf};
1412
use std::time::{Instant, SystemTime};
1513

14+
use crate::listings::{DirectoryListing, ListingKind};
15+
use crate::{AnalysisLoader, Blacklist};
16+
1617
#[derive(Debug)]
1718
pub struct Crate {
1819
pub id: CrateId,

rls-vfs/src/lib.rs

+12-6
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)