Skip to content

Commit 3836dfb

Browse files
committed
Split Job::new into Job::new_fresh and Job::new_dirty
1 parent 0c5f6f0 commit 3836dfb

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

src/cargo/core/compiler/custom_build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
432432
});
433433

434434
let mut job = if cx.bcx.build_config.build_plan {
435-
Job::new(Work::noop(), Freshness::Dirty)
435+
Job::new_dirty(Work::noop())
436436
} else {
437437
fingerprint::prepare_target(cx, unit, false)?
438438
};

src/cargo/core/compiler/fingerprint.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,7 @@ use crate::util::paths;
337337
use crate::util::{internal, profile, ProcessBuilder};
338338

339339
use super::custom_build::BuildDeps;
340-
use super::job::{
341-
Freshness::{Dirty, Fresh},
342-
Job, Work,
343-
};
340+
use super::job::{Job, Work};
344341
use super::{BuildContext, Context, FileFlavor, Unit};
345342

346343
/// Determines if a `unit` is up-to-date, and if not prepares necessary work to
@@ -396,7 +393,7 @@ pub fn prepare_target(cx: &mut Context<'_, '_>, unit: &Unit, force: bool) -> Car
396393
}
397394

398395
if compare.is_ok() && !force {
399-
return Ok(Job::new(Work::noop(), Fresh));
396+
return Ok(Job::new_fresh());
400397
}
401398

402399
// Clear out the old fingerprint file if it exists. This protects when
@@ -469,7 +466,7 @@ pub fn prepare_target(cx: &mut Context<'_, '_>, unit: &Unit, force: bool) -> Car
469466
Work::new(move |_| write_fingerprint(&loc, &fingerprint))
470467
};
471468

472-
Ok(Job::new(write_fingerprint, Dirty))
469+
Ok(Job::new_dirty(write_fingerprint))
473470
}
474471

475472
/// Dependency edge information for fingerprints. This is generated for each

src/cargo/core/compiler/job.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,20 @@ impl Work {
4040
}
4141

4242
impl Job {
43+
/// Creates a new job that does nothing.
44+
pub fn new_fresh() -> Job {
45+
Job {
46+
work: Work::noop(),
47+
fresh: Freshness::Fresh,
48+
}
49+
}
50+
4351
/// Creates a new job representing a unit of work.
44-
pub fn new(work: Work, fresh: Freshness) -> Job {
45-
Job { work, fresh }
52+
pub fn new_dirty(work: Work) -> Job {
53+
Job {
54+
work,
55+
fresh: Freshness::Dirty,
56+
}
4657
}
4758

4859
/// Consumes this job by running it, returning the result of the

src/cargo/core/compiler/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ fn compile<'cfg>(
130130
custom_build::prepare(cx, unit)?
131131
} else if unit.mode.is_doc_test() {
132132
// We run these targets later, so this is just a no-op for now.
133-
Job::new(Work::noop(), Freshness::Fresh)
133+
Job::new_fresh()
134134
} else if build_plan {
135-
Job::new(rustc(cx, unit, &exec.clone())?, Freshness::Dirty)
135+
Job::new_dirty(rustc(cx, unit, &exec.clone())?)
136136
} else {
137137
let force = exec.force_rebuild(unit) || force_rebuild;
138138
let mut job = fingerprint::prepare_target(cx, unit, force)?;

0 commit comments

Comments
 (0)