Skip to content

Commit

Permalink
Moves error-checking from toolchain_link into install_from_dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
theindigamer committed Apr 5, 2017
1 parent 27202ac commit bdc7c3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 7,7 @@ use rustup_dist::manifest::Component;
use rustup_dist::dist::{TargetTriple, PartialToolchainDesc, PartialTargetTriple};
use rustup_utils::utils;
use self_update;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::process::Command;
use std::iter;
use term2;
Expand Down Expand Up @@ -688,15 688,7 @@ fn toolchain_link(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
let ref toolchain = m.value_of("toolchain").expect("");
let ref path = m.value_of("path").expect("");
let toolchain = try!(cfg.get_toolchain(toolchain, true));
let mut pathbuf = PathBuf::from(path);

pathbuf.push("lib");
try!(utils::assert_is_directory(&pathbuf));
pathbuf.pop();
pathbuf.push("bin");
try!(utils::assert_is_directory(&pathbuf));
pathbuf.push("rustc");
try!(utils::assert_is_file(&pathbuf));

Ok(try!(toolchain.install_from_dir(Path::new(path), true)))
}

Expand Down
10 changes: 10 additions & 0 deletions src/rustup/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 273,16 @@ impl<'a> Toolchain<'a> {
}

pub fn install_from_dir(&self, src: &Path, link: bool) -> Result<()> {
let mut pathbuf = PathBuf::from(src);

pathbuf.push("lib");
try!(utils::assert_is_directory(&pathbuf));
pathbuf.pop();
pathbuf.push("bin");
try!(utils::assert_is_directory(&pathbuf));
pathbuf.push("rustc");
try!(utils::assert_is_file(&pathbuf));

try!(self.ensure_custom());

if link {
Expand Down

0 comments on commit bdc7c3a

Please sign in to comment.