Skip to content

Commit bdc7c3a

Browse files
author
theindigamer
committed
Moves error-checking from toolchain_link into install_from_dir.
1 parent 27202ac commit bdc7c3a

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/rustup-cli/rustup_mode.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustup_dist::manifest::Component;
77
use rustup_dist::dist::{TargetTriple, PartialToolchainDesc, PartialTargetTriple};
88
use rustup_utils::utils;
99
use self_update;
10-
use std::path::{Path, PathBuf};
10+
use std::path::Path;
1111
use std::process::Command;
1212
use std::iter;
1313
use term2;
@@ -688,15 +688,7 @@ fn toolchain_link(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
688688
let ref toolchain = m.value_of("toolchain").expect("");
689689
let ref path = m.value_of("path").expect("");
690690
let toolchain = try!(cfg.get_toolchain(toolchain, true));
691-
let mut pathbuf = PathBuf::from(path);
692-
693-
pathbuf.push("lib");
694-
try!(utils::assert_is_directory(&pathbuf));
695-
pathbuf.pop();
696-
pathbuf.push("bin");
697-
try!(utils::assert_is_directory(&pathbuf));
698-
pathbuf.push("rustc");
699-
try!(utils::assert_is_file(&pathbuf));
691+
700692
Ok(try!(toolchain.install_from_dir(Path::new(path), true)))
701693
}
702694

src/rustup/toolchain.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ impl<'a> Toolchain<'a> {
273273
}
274274

275275
pub fn install_from_dir(&self, src: &Path, link: bool) -> Result<()> {
276+
let mut pathbuf = PathBuf::from(src);
277+
278+
pathbuf.push("lib");
279+
try!(utils::assert_is_directory(&pathbuf));
280+
pathbuf.pop();
281+
pathbuf.push("bin");
282+
try!(utils::assert_is_directory(&pathbuf));
283+
pathbuf.push("rustc");
284+
try!(utils::assert_is_file(&pathbuf));
285+
276286
try!(self.ensure_custom());
277287

278288
if link {

0 commit comments

Comments
 (0)