Skip to content

Commit 57cdda3

Browse files
committed
Rust: no longer reload files into the RootDatabase
Files were reloaded to handle cases were there was no content for a file_id, causing a panic. Missing contents was caused by files that did not contain valid UTF-8 data. These are skipped by rust-analyzer when it is loading data into the RootDatabase.
1 parent b112a9b commit 57cdda3

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

rust/extractor/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod translate;
1717
pub mod trap;
1818

1919
fn extract(
20-
rust_analyzer: &mut rust_analyzer::RustAnalyzer,
20+
rust_analyzer: &rust_analyzer::RustAnalyzer,
2121
archiver: &Archiver,
2222
traps: &trap::TrapFileProvider,
2323
file: &std::path::Path,

rust/extractor/src/rust_analyzer.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use itertools::Itertools;
22
use log::{debug, info};
33
use ra_ap_base_db::SourceDatabase;
4-
use ra_ap_base_db::SourceDatabaseFileInputExt;
54
use ra_ap_hir::Semantics;
65
use ra_ap_ide_db::RootDatabase;
76
use ra_ap_load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
@@ -57,7 +56,7 @@ impl RustAnalyzer {
5756
}
5857
}
5958
}
60-
pub fn parse(&mut self, path: &Path) -> ParseResult<'_> {
59+
pub fn parse(&self, path: &Path) -> ParseResult<'_> {
6160
let mut errors = Vec::new();
6261
let input = match std::fs::read(path) {
6362
Ok(data) => data,
@@ -78,7 +77,6 @@ impl RustAnalyzer {
7877
.map(VfsPath::from)
7978
.and_then(|x| vfs.file_id(&x))
8079
{
81-
db.set_file_text(file_id, &input);
8280
let semantics = Semantics::new(db);
8381

8482
let file_id = EditionedFileId::current_edition(file_id);

0 commit comments

Comments
 (0)