+ // Clear the output directory if the real rustc we're using has changed;
+ // Cargo cannot detect this as it thinks rustc is bootstrap/debug/rustc.
+ //
+ // Avoid doing this during dry run as that usually means the relevant
+ // compiler is not yet linked/copied properly.
+ //
+ // Only clear out the directory if we're compiling std; otherwise, we
+ // should let Cargo take care of things for us (via depdep info)
+ if !self.config.dry_run && mode == Mode::ToolStd && cmd == "build" {
+ self.clear_if_dirty(&out_dir, &self.rustc(compiler));
+ }
+