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

Commit 8a20acc

Browse files
committed
Address feedback
1 parent 6dc203d commit 8a20acc

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/build/plan.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ impl Plan {
216216
.max();
217217

218218
match max_matching_prefix {
219-
Some(0) => error!("Modified file didn't correspond to any buildable unit!"),
219+
Some(0) => error!("Modified file {} didn't correspond to any buildable unit!",
220+
modified.display()),
220221
Some(max) => {
221222
let dirty_units = other_targets.iter()
222223
.filter(|(_, dir)| max == matching_prefix_components(modified, dir))
@@ -479,7 +480,13 @@ impl PackageMap {
479480

480481
crate struct JobQueue(Vec<ProcessBuilder>);
481482

482-
fn proc_arg<T: AsRef<OsStr>>(prc: &ProcessBuilder, key: T) -> Option<&std::ffi::OsStr> {
483+
/// Returns an immediately next argument to the one specified in a given
484+
/// ProcessBuilder (or `None` if the searched or the next argument could not be found).
485+
///
486+
/// This is useful for returning values for arguments of `--key <value>` format.
487+
/// For example, if `[.., "--crate-name", "rls", ...]` arguments are specified,
488+
/// then proc_arg(prc, "--crate-name") returns Some(&OsStr::new("rls"));
489+
fn proc_argument_value<T: AsRef<OsStr>>(prc: &ProcessBuilder, key: T) -> Option<&std::ffi::OsStr> {
483490
let args = prc.get_args();
484491
let (idx, _) = args.iter().enumerate()
485492
.find(|(_, arg)| arg.as_os_str() == key.as_ref())?;
@@ -491,8 +498,9 @@ impl fmt::Debug for JobQueue {
491498
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
492499
write!(f, "JobQueue: [")?;
493500
for prog in self.0.iter().rev() {
494-
let name = proc_arg(prog, "--crate-name").unwrap();
495-
let typ_ = proc_arg(prog, "--crate-type").unwrap_or_else(|| OsStr::new("<unknown>"));
501+
let name = proc_argument_value(prog, "--crate-name").unwrap();
502+
let typ_ = proc_argument_value(prog, "--crate-type")
503+
.unwrap_or_else(|| OsStr::new("<unknown>"));
496504
write!(f, "{:?} ({:?}), ", name, typ_);
497505
}
498506
write!(f, "]")?;
@@ -545,7 +553,8 @@ impl JobQueue {
545553

546554
// Send a window/progress notification.
547555
{
548-
let crate_name = proc_arg(&job, "--crate-name").and_then(|x| x.to_str());
556+
let crate_name = proc_argument_value(&job, "--crate-name")
557+
.and_then(|x| x.to_str());
549558
let update = match crate_name {
550559
Some(name) => ProgressUpdate::Message(name.to_owned()),
551560
None => {

0 commit comments

Comments
 (0)