Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit a763e65

Browse files
committed
Address review feedback
1 parent e1707f9 commit a763e65

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/build/plan.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use cargo::util::{CargoResult, ProcessBuilder};
3939
use cargo_metadata;
4040
use crate::lsp_data::parse_file_path;
4141
use url::Url;
42-
use log::{log, trace};
42+
use log::{log, trace, error};
4343

4444
use crate::actions::progress::ProgressUpdate;
4545
use super::{BuildResult, Internals};
@@ -94,8 +94,8 @@ impl Plan {
9494
/// `PackageId` and `TargetKind` in `Target`, to be used when processing
9595
/// cached build plan.
9696
crate fn cache_compiler_job(&mut self, id: &PackageId, target: &Target, mode: CompileMode, cmd: &ProcessBuilder) {
97-
let pkg_key = (id.clone(), target.clone(), mode);
98-
self.compiler_jobs.insert(pkg_key, cmd.clone());
97+
let unit_key = (id.clone(), target.clone(), mode);
98+
self.compiler_jobs.insert(unit_key, cmd.clone());
9999
}
100100

101101
/// Emplace a given `Unit`, along with its `Unit` dependencies (recursively)
@@ -213,17 +213,18 @@ impl Plan {
213213
// collect every unit having the longest path prefix.
214214
let max_matching_prefix = other_targets.values()
215215
.map(|src_dir| matching_prefix_components(modified, src_dir))
216-
.max().unwrap();
216+
.max();
217217

218-
if max_matching_prefix == 0 {
219-
trace!("Modified file didn't correspond to any buildable unit!");
220-
} else {
221-
let dirty_units = other_targets.iter()
222-
.filter(|(_, src_dir)| max_matching_prefix ==
223-
matching_prefix_components(modified, src_dir)
224-
).map(|(unit, _)| unit);
218+
match max_matching_prefix {
219+
Some(0) => error!("Modified file didn't correspond to any buildable unit!"),
220+
Some(max) => {
221+
let dirty_units = other_targets.iter()
222+
.filter(|(_, dir)| max == matching_prefix_components(modified, dir))
223+
.map(|(unit, _)| unit);
225224

226-
result.extend(dirty_units.cloned());
225+
result.extend(dirty_units.cloned());
226+
}
227+
None => {} // Possible that only build scripts were modified
227228
}
228229
}
229230
}

0 commit comments

Comments
 (0)