From a64575c3bd81f6f169eff22a4884984c9c5b36c0 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Tue, 13 Feb 2018 18:42:26 -0700 Subject: [PATCH] Fix default Steps without paths. Some Steps are by-default run but don't have any paths associated with them. We need to have at least one PathSet per each Step, though, so we add an empty one on calls to `never()`. --- src/bootstrap/builder.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index cbd303e114066..c00138d85e149 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -95,7 +95,7 @@ pub struct RunConfig<'a> { pub builder: &'a Builder<'a>, pub host: Interned, pub target: Interned, - pub path: &'a Path, + pub path: PathBuf, } struct StepDescription { @@ -114,6 +114,10 @@ struct PathSet { } impl PathSet { + fn empty() -> PathSet { + PathSet { set: BTreeSet::new() } + } + fn one>(path: P) -> PathSet { let mut set = BTreeSet::new(); set.insert(path.into()); @@ -124,8 +128,8 @@ impl PathSet { self.set.iter().any(|p| p.ends_with(needle)) } - fn path(&self) -> &Path { - self.set.iter().next().unwrap() + fn path(&self, builder: &Builder) -> PathBuf { + self.set.iter().next().unwrap_or(&builder.build.src).to_path_buf() } } @@ -174,7 +178,7 @@ impl StepDescription { for target in targets { let run = RunConfig { builder, - path: pathset.path(), + path: pathset.path(builder), host: *host, target: *target, }; @@ -278,7 +282,8 @@ impl<'a> ShouldRun<'a> { } // allows being more explicit about why should_run in Step returns the value passed to it - pub fn never(self) -> ShouldRun<'a> { + pub fn never(mut self) -> ShouldRun<'a> { + self.paths.insert(PathSet::empty()); self }