Skip to content

Commit c634b0a

Browse files
committed
Don't extract non-source crates
1 parent 197fb04 commit c634b0a

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

rust/extractor/src/main.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ fn main() -> anyhow::Result<()> {
6565
let crates = <dyn DefDatabase>::crate_graph(&db);
6666
for crate_id in crates.iter() {
6767
let krate = Crate::from(crate_id);
68+
if !cfg.extract_dependencies && !krate.origin(&db).is_local() {
69+
continue;
70+
}
6871
let name = krate.display_name(&db);
6972
let crate_name = name
7073
.as_ref()
@@ -78,16 +81,9 @@ fn main() -> anyhow::Result<()> {
7881
crate_id.into_raw().into_u32()
7982
)),
8083
);
81-
translate::CrateTranslator::new(
82-
&db,
83-
trap,
84-
&krate,
85-
&vfs,
86-
&archiver,
87-
cfg.extract_dependencies,
88-
)
89-
.emit_crate()
90-
.context("writing trap file")?;
84+
translate::CrateTranslator::new(&db, trap, &krate, &vfs, &archiver)
85+
.emit_crate()
86+
.context("writing trap file")?;
9187
}
9288
}
9389
Ok(())

rust/extractor/src/translate.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub struct CrateTranslator<'a> {
3232
krate: &'a Crate,
3333
vfs: &'a Vfs,
3434
archiver: &'a Archiver,
35-
extract_dependencies: bool,
3635
file_labels: HashMap<PathBuf, FileData>,
3736
}
3837

@@ -43,15 +42,13 @@ impl CrateTranslator<'_> {
4342
krate: &'a Crate,
4443
vfs: &'a Vfs,
4544
archiver: &'a Archiver,
46-
extract_dependencies: bool,
4745
) -> CrateTranslator<'a> {
4846
CrateTranslator {
4947
db,
5048
trap,
5149
krate,
5250
vfs,
5351
archiver,
54-
extract_dependencies,
5552
file_labels: HashMap::new(),
5653
}
5754
}
@@ -942,17 +939,11 @@ impl CrateTranslator<'_> {
942939
let name = function.name(self.db);
943940
let location = self.emit_location(function);
944941

945-
let body = if self.extract_dependencies || self.krate.origin(self.db).is_local() {
946-
let (body, source_map) = self.db.body_with_source_map(def.into());
947-
let txt = body.pretty_print(self.db, def.into(), Edition::Edition2021);
948-
log::trace!("{}", &txt);
949-
self.emit_expr(body.body_expr, &body, &source_map)
950-
} else {
951-
self.trap.emit(generated::MissingExpr {
952-
id: TrapId::Star,
953-
location: None,
954-
})
955-
};
942+
let (body, source_map) = self.db.body_with_source_map(def.into());
943+
let txt = body.pretty_print(self.db, def.into(), Edition::Edition2021);
944+
log::trace!("{}", &txt);
945+
let body = self.emit_expr(body.body_expr, &body, &source_map);
946+
956947
labels.push(self.trap.emit(generated::Function {
957948
id: trap_key![module_label, name.as_str()],
958949
location,

0 commit comments

Comments
 (0)