Rust: Remove ResolvePaths enum and resolve_paths arguments up to Translator::new (hardcode to false).

This commit is contained in:
Geoffrey White
2025-08-26 09:41:50 +01:00
parent d6d0645d7b
commit 456f56096f
3 changed files with 9 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
use crate::diagnostics::{ExtractionStep, emit_extraction_diagnostics};
use crate::rust_analyzer::path_to_file_id;
use crate::translate::{ResolvePaths, SourceKind};
use crate::translate::SourceKind;
use crate::trap::TrapId;
use anyhow::Context;
use archive::Archiver;
@@ -54,7 +54,6 @@ impl<'a> Extractor<'a> {
&mut self,
rust_analyzer: &RustAnalyzer,
file: &Path,
resolve_paths: ResolvePaths,
source_kind: SourceKind,
) {
self.archiver.archive(file);
@@ -79,7 +78,6 @@ impl<'a> Extractor<'a> {
label,
line_index,
semantics_info.as_ref().ok(),
resolve_paths,
source_kind,
);
@@ -120,13 +118,11 @@ impl<'a> Extractor<'a> {
file: &Path,
semantics: &Semantics<'_, RootDatabase>,
vfs: &Vfs,
resolve_paths: ResolvePaths,
source_kind: SourceKind,
) {
self.extract(
&RustAnalyzer::new(vfs, semantics),
file,
resolve_paths,
source_kind,
);
}
@@ -140,7 +136,6 @@ impl<'a> Extractor<'a> {
self.extract(
&RustAnalyzer::WithoutSemantics { reason },
file,
ResolvePaths::No,
source_kind,
);
}
@@ -283,16 +278,15 @@ fn main() -> anyhow::Result<()> {
}
let cwd = cwd()?;
let (cargo_config, load_cargo_config) = cfg.to_cargo_config(&cwd);
let resolve_paths = ResolvePaths::No;
let (library_mode, library_resolve_paths) = if cfg.extract_dependencies_as_source {
(SourceKind::Source, resolve_paths)
let library_mode = if cfg.extract_dependencies_as_source {
SourceKind::Source
} else {
(SourceKind::Library, ResolvePaths::No)
SourceKind::Library
};
let (source_mode, source_resolve_paths) = if cfg.force_library_mode {
(library_mode, library_resolve_paths)
let source_mode = if cfg.force_library_mode {
library_mode
} else {
(SourceKind::Source, resolve_paths)
SourceKind::Source
};
let mut processed_files: HashSet<PathBuf, RandomState> =
HashSet::from_iter(files.iter().cloned());
@@ -312,7 +306,6 @@ fn main() -> anyhow::Result<()> {
file,
&semantics,
vfs,
source_resolve_paths,
source_mode,
),
Err(reason) => extractor.extract_without_semantics(file, source_mode, &reason),
@@ -331,7 +324,6 @@ fn main() -> anyhow::Result<()> {
file,
&semantics,
vfs,
library_resolve_paths,
library_mode,
);
extractor.archiver.archive(file);

View File

@@ -2,4 +2,4 @@ mod base;
mod generated;
mod mappings;
pub use base::{ResolvePaths, SourceKind, Translator};
pub use base::{SourceKind, Translator};

View File

@@ -175,11 +175,6 @@ macro_rules! dispatch_to_tracing {
};
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum ResolvePaths {
Yes,
No,
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum SourceKind {
Source,
@@ -211,7 +206,6 @@ impl<'a> Translator<'a> {
label: Label<generated::File>,
line_index: LineIndex,
semantic_info: Option<&FileSemanticInformation<'a>>,
resolve_paths: ResolvePaths,
source_kind: SourceKind,
) -> Translator<'a> {
Translator {
@@ -221,7 +215,7 @@ impl<'a> Translator<'a> {
line_index,
file_id: semantic_info.map(|i| i.file_id),
semantics: semantic_info.map(|i| i.semantics),
resolve_paths: resolve_paths == ResolvePaths::Yes,
resolve_paths: false,
source_kind,
macro_context_depth: 0,
diagnostic_count: 0,