Skip to content

Commit b62d52e

Browse files
committed
Rust: prevent source files from being extracted in both source and library mode
When analysing a repository with multiple separate but related sub-projects there is a risk that some source file are extracted in library mode as well as source mode. To prevent this we pre-fill 'processed_files' set with all source files, even though they have not be processed yet, but are known to be processed later.. This prevents source file to be
1 parent df99e06 commit b62d52e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rust/extractor/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use ra_ap_project_model::{CargoConfig, ProjectManifest};
1414
use ra_ap_vfs::Vfs;
1515
use rust_analyzer::{ParseResult, RustAnalyzer};
1616
use std::collections::HashSet;
17+
use std::hash::RandomState;
1718
use std::time::Instant;
1819
use std::{
1920
collections::HashMap,
@@ -276,7 +277,8 @@ fn main() -> anyhow::Result<()> {
276277
} else {
277278
ResolvePaths::Yes
278279
};
279-
let mut processed_files = HashSet::new();
280+
let mut processed_files: HashSet<PathBuf, RandomState> =
281+
HashSet::from_iter(files.iter().cloned());
280282
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
281283
if let Some((ref db, ref vfs)) =
282284
extractor.load_manifest(manifest, &cargo_config, &load_cargo_config)
@@ -288,7 +290,6 @@ fn main() -> anyhow::Result<()> {
288290
.push(ExtractionStep::crate_graph(before_crate_graph));
289291
let semantics = Semantics::new(db);
290292
for file in files {
291-
processed_files.insert((*file).to_owned());
292293
match extractor.load_source(file, &semantics, vfs) {
293294
Ok(()) => extractor.extract_with_semantics(
294295
file,

0 commit comments

Comments
 (0)