Skip to content

Commit c87f2c4

Browse files
committed
Rust: remove unnecessary field
1 parent b6c26de commit c87f2c4

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

rust/extractor/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ fn main() -> anyhow::Result<()> {
114114
}
115115
if let Some((ref db, ref vfs)) = RustAnalyzer::load_workspace(manifest, &cfg.scratch_dir) {
116116
let semantics = Semantics::new(db);
117-
let rust_analyzer = RustAnalyzer::new(db, vfs, semantics);
117+
let rust_analyzer = RustAnalyzer::new(vfs, semantics);
118118
for file in files {
119119
extract(&rust_analyzer, &archiver, &traps, file);
120120
}
121121
} else {
122122
for file in files {
123-
extract(&RustAnalyzer::WithoutDatabase(), &archiver, &traps, file);
123+
extract(&RustAnalyzer::WithoutSemantics, &archiver, &traps, file);
124124
}
125125
}
126126
}
127127
for file in other_files {
128-
extract(&RustAnalyzer::WithoutDatabase(), &archiver, &traps, file);
128+
extract(&RustAnalyzer::WithoutSemantics, &archiver, &traps, file);
129129
}
130130

131131
Ok(())

rust/extractor/src/rust_analyzer.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ use std::borrow::Cow;
2121
use std::path::{Path, PathBuf};
2222
use triomphe::Arc;
2323
pub enum RustAnalyzer<'a> {
24-
WithDatabase {
25-
db: &'a RootDatabase,
24+
WithSemantics {
2625
vfs: &'a Vfs,
2726
semantics: Semantics<'a, RootDatabase>,
2827
},
29-
WithoutDatabase(),
28+
WithoutSemantics,
3029
}
3130
pub struct ParseResult {
3231
pub ast: SourceFile,
@@ -62,31 +61,28 @@ impl<'a> RustAnalyzer<'a> {
6261
}
6362
}
6463
}
65-
pub fn new(db: &'a RootDatabase, vfs: &'a Vfs, semantics: Semantics<'a, RootDatabase>) -> Self {
66-
RustAnalyzer::WithDatabase { db, vfs, semantics }
64+
pub fn new(vfs: &'a Vfs, semantics: Semantics<'a, RootDatabase>) -> Self {
65+
RustAnalyzer::WithSemantics { vfs, semantics }
6766
}
6867
pub fn semantics(&'a self) -> Option<&'a Semantics<'a, RootDatabase>> {
6968
match self {
70-
RustAnalyzer::WithDatabase {
71-
db: _,
72-
vfs: _,
73-
semantics,
74-
} => Some(semantics),
75-
RustAnalyzer::WithoutDatabase() => None,
69+
RustAnalyzer::WithSemantics { vfs: _, semantics } => Some(semantics),
70+
RustAnalyzer::WithoutSemantics => None,
7671
}
7772
}
7873
pub fn parse(&self, path: &Path) -> ParseResult {
79-
if let RustAnalyzer::WithDatabase { vfs, db, semantics } = self {
74+
if let RustAnalyzer::WithSemantics { vfs, semantics } = self {
8075
if let Some(file_id) = Utf8PathBuf::from_path_buf(path.to_path_buf())
8176
.ok()
8277
.and_then(|x| AbsPathBuf::try_from(x).ok())
8378
.map(VfsPath::from)
8479
.and_then(|x| vfs.file_id(&x))
8580
{
86-
let input: Arc<str> = db.file_text(file_id);
81+
let input: Arc<str> = semantics.db.file_text(file_id);
8782
let file_id = EditionedFileId::current_edition(file_id);
8883
let source_file = semantics.parse(file_id);
89-
let errors = db
84+
let errors = semantics
85+
.db
9086
.parse_errors(file_id)
9187
.into_iter()
9288
.flat_map(|x| x.to_vec())

0 commit comments

Comments
 (0)