Skip to content

Commit 19d28a9

Browse files
committed
Assert incr comp in copy_cgu_workproduct_to_incr_comp_cache_dir
It was already only called when incr comp is enabled and this allows cleaning up the callers a bit.
1 parent 5ec82ec commit 19d28a9

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,13 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
489489
if let Some(path) = &module.bytecode {
490490
files.push((OutputType::Bitcode.extension(), path.as_path()));
491491
}
492-
if let Some((id, product)) = copy_cgu_workproduct_to_incr_comp_cache_dir(
492+
let (id, product) = copy_cgu_workproduct_to_incr_comp_cache_dir(
493493
sess,
494494
&module.name,
495495
files.as_slice(),
496496
&module.links_from_incr_cache,
497-
) {
498-
work_products.insert(id, product);
499-
}
497+
);
498+
work_products.insert(id, product);
500499
}
501500

502501
work_products

compiler/rustc_incremental/src/persist/work_product.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ use crate::persist::fs::*;
1616

1717
/// Copies a CGU work product to the incremental compilation directory, so next compilation can
1818
/// find and reuse it.
19+
///
20+
/// Panics when incr comp is disabled.
1921
pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
2022
sess: &Session,
2123
cgu_name: &str,
2224
files: &[(&'static str, &Path)],
2325
known_links: &[PathBuf],
24-
) -> Option<(WorkProductId, WorkProduct)> {
26+
) -> (WorkProductId, WorkProduct) {
2527
debug!(?cgu_name, ?files);
26-
sess.opts.incremental.as_ref()?;
28+
assert!(sess.opts.incremental.is_some());
2729

2830
let mut saved_files = UnordMap::default();
2931
for (ext, path) in files {
@@ -50,7 +52,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
5052
let work_product = WorkProduct { cgu_name: cgu_name.to_string(), saved_files };
5153
debug!(?work_product);
5254
let work_product_id = WorkProductId::from_cgu_name(cgu_name);
53-
Some((work_product_id, work_product))
55+
(work_product_id, work_product)
5456
}
5557

5658
/// Removes files for a given work product.

compiler/rustc_interface/src/queries.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ impl Linker {
8989

9090
if sess.opts.incremental.is_some()
9191
&& let Some(path) = self.metadata.path()
92-
&& let Some((id, product)) =
93-
rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(
94-
sess,
95-
"metadata",
96-
&[("rmeta", path)],
97-
&[],
98-
)
9992
{
93+
let (id, product) = rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(
94+
sess,
95+
"metadata",
96+
&[("rmeta", path)],
97+
&[],
98+
);
10099
work_products.insert(id, product);
101100
}
102101

0 commit comments

Comments
 (0)