Skip to content

Commit cd0074b

Browse files
committed
Merge branch 'master' into db-bump-version
# Conflicts: # Cargo.lock
2 parents 1086892 + a675b7e commit cd0074b

File tree

13 files changed

+874
-485
lines changed

13 files changed

+874
-485
lines changed

Cargo.lock

Lines changed: 683 additions & 454 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ rustup-dist = { path = "src/rustup-dist" }
3535
rustup-utils = { path = "src/rustup-utils" }
3636
download = { path = "src/download" }
3737
clap = "2.18.0"
38-
error-chain = "0.11"
38+
error-chain = "0.12.0"
3939
itertools = "0.7.6"
4040
libc = "0.2.0"
4141
markdown = "0.2"
42-
rand = "0.4.2"
43-
regex = "0.2"
44-
remove_dir_all = "0.3.0"
42+
rand = "0.5.2"
43+
regex = "1.0.1"
44+
remove_dir_all = "0.5.1"
4545
same-file = "1.0"
4646
scopeguard = "0.3"
4747
serde = "1.0"
4848
serde_derive = "1.0"
4949
serde_json = "1.0"
5050
sha2 = "0.7.0"
5151
tempdir = "0.3.4"
52-
tempfile = "2.1.4"
52+
tempfile = "3.0.2"
5353
term = "0.5.1"
5454
time = "0.1.34"
5555
toml = "0.4"

src/download/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ curl-backend = ["curl"]
1414
reqwest-backend = ["reqwest", "env_proxy", "lazy_static"]
1515

1616
[dependencies]
17-
error-chain = "0.11"
17+
error-chain = "0.12"
1818
url = "1.2"
1919
curl = { version = "0.4.6", optional = true }
2020
env_proxy = { version = "0.2.0", optional = true }

src/rustup-cli/help.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ pub static SHOW_HELP: &'static str = r"DISCUSSION:
1717
If there are multiple toolchains installed then all installed
1818
toolchains are listed as well.";
1919

20+
pub static SHOW_ACTIVE_TOOLCHAIN_HELP: &'static str = r"DISCUSSION:
21+
Shows the name of the active toolchain.
22+
23+
This is useful for figuring out the active tool chain from
24+
scripts.
25+
26+
You should use `rustc --print sysroot` to get the sysroot, or
27+
`rustc --version` to get the toolchain version.";
28+
2029
pub static UPDATE_HELP: &'static str = r"DISCUSSION:
2130
With no toolchain specified, the `update` command updates each of
2231
the installed toolchains from the official release channels, then

src/rustup-cli/rustup_mode.rs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ pub fn main() -> Result<()> {
2929
cfg.check_metadata_version()?;
3030

3131
match matches.subcommand() {
32-
("show", Some(_)) => show(cfg)?,
32+
("show", Some(c)) => match c.subcommand() {
33+
("active-toolchain", Some(_)) => show_active_toolchain(cfg)?,
34+
(_, _) => show(cfg)?
35+
},
3336
("install", Some(m)) => update(cfg, m)?,
3437
("update", Some(m)) => update(cfg, m)?,
3538
("uninstall", Some(m)) => toolchain_remove(cfg, m)?,
@@ -110,7 +113,13 @@ pub fn cli() -> App<'static, 'static> {
110113
.subcommand(
111114
SubCommand::with_name("show")
112115
.about("Show the active and installed toolchains")
113-
.after_help(SHOW_HELP),
116+
.after_help(SHOW_HELP)
117+
.setting(AppSettings::VersionlessSubcommands)
118+
.setting(AppSettings::DeriveDisplayOrder)
119+
.subcommand(SubCommand::with_name("active-toolchain")
120+
.about("Show the active toolchain")
121+
.after_help(SHOW_ACTIVE_TOOLCHAIN_HELP)
122+
),
114123
)
115124
.subcommand(
116125
SubCommand::with_name("install")
@@ -360,6 +369,11 @@ pub fn cli() -> App<'static, 'static> {
360369
.alias("docs")
361370
.about("Open the documentation for the current toolchain")
362371
.after_help(DOC_HELP)
372+
.arg(
373+
Arg::with_name("path")
374+
.long("path")
375+
.help("Only print the path to the documentation"),
376+
)
363377
.arg(
364378
Arg::with_name("book")
365379
.long("book")
@@ -733,6 +747,19 @@ fn show(cfg: &Cfg) -> Result<()> {
733747
Ok(())
734748
}
735749

750+
fn show_active_toolchain(cfg: &Cfg) -> Result<()> {
751+
let ref cwd = utils::current_dir()?;
752+
match cfg.find_override_toolchain_or_default(cwd)? {
753+
Some((ref toolchain, _)) => {
754+
println!("{}", toolchain.name());
755+
},
756+
None => {
757+
// Print nothing
758+
}
759+
}
760+
Ok(())
761+
}
762+
736763
fn target_list(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
737764
let toolchain = explicit_or_dir_toolchain(cfg, m)?;
738765

@@ -929,7 +956,14 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
929956
"index.html"
930957
};
931958

932-
Ok(cfg.open_docs_for_dir(&utils::current_dir()?, doc_url)?)
959+
let cwd = &utils::current_dir()?;
960+
if m.is_present("path") {
961+
let doc_path = try!(cfg.doc_path_for_dir(cwd, doc_url));
962+
println!("{}", doc_path.display());
963+
Ok(())
964+
} else {
965+
Ok(cfg.open_docs_for_dir(cwd, doc_url)?)
966+
}
933967
}
934968

935969
fn man(cfg: &Cfg, m: &ArgMatches) -> Result<()> {

src/rustup-dist/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repository = "https://github.com/rust-lang-nursery/rustup.rs"
1313
license = "MIT OR Apache-2.0"
1414

1515
[dependencies]
16-
regex = "0.2.0"
16+
regex = "1.0.1"
1717
itertools = "0.7"
1818
ole32-sys = "0.2.0"
1919
url = "1.1.0"
@@ -23,9 +23,9 @@ xz2 = "0.1.3"
2323
walkdir = "2.0"
2424
toml = "0.4"
2525
sha2 = "0.7.0"
26-
remove_dir_all = "0.3"
26+
remove_dir_all = "0.5.1"
2727
rustup-utils = { path = "../rustup-utils" }
28-
error-chain = "0.11"
28+
error-chain = "0.12"
2929

3030
[dev-dependencies]
3131
rustup-mock = { path = "../rustup-mock" }
@@ -40,4 +40,3 @@ libc = "0.2.0"
4040

4141
[lib]
4242
name = "rustup_dist"
43-

src/rustup-mock/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ wait-timeout = "0.1.3"
2424
[target."cfg(windows)".dependencies]
2525
winapi = "0.3"
2626
winreg = "0.5.0"
27-

src/rustup-utils/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ license = "MIT OR Apache-2.0"
1313

1414
[dependencies]
1515
download = { path = "../download" }
16-
error-chain = "0.11"
16+
error-chain = "0.12"
1717
libc = "0.2.0"
18-
rand = "0.4.2"
19-
remove_dir_all = "0.3.0"
18+
rand = "0.5.2"
19+
remove_dir_all = "0.5.1"
2020
scopeguard = "0.3.0"
2121
semver = "0.9.0"
2222
sha2 = "0.7.0"
2323
toml = "0.4"
2424
url = "1.1"
2525

2626
[target."cfg(windows)".dependencies]
27-
winapi = { version = "0.3", features = ["combaseapi", "errhandlingapi", "fileapi", "handleapi",
27+
winapi = { version = "0.3", features = ["combaseapi", "errhandlingapi", "fileapi", "handleapi",
2828
"ioapiset", "minwindef", "processthreadsapi", "shlobj", "shtypes", "userenv", "winbase", "winerror", "winnt", "winioctl"] }
2929
winreg = "0.5.0"

src/rustup/telemetry_analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl TelemetryAnalysis {
240240
self.rustc_error_statistics.error_codes_with_counts = error_codes_with_counts;
241241
self.rustc_success_statistics = compute_rustc_percentiles(&rustc_successful_durations);
242242

243-
let error_list = error_list.into_iter().flatten();
243+
let error_list = Itertools::flatten(error_list.into_iter());
244244

245245
for e in error_list {
246246
let error_count = self.rustc_statistics

tests/cli-rustup.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern crate tempdir;
77

88
use std::fs;
99
use std::env::consts::EXE_SUFFIX;
10+
use std::path::MAIN_SEPARATOR;
1011
use std::process;
1112
use rustup_utils::raw;
1213
use rustup_mock::clitools::{self, expect_err, expect_ok, expect_ok_ex, expect_stderr_ok,
@@ -845,6 +846,34 @@ fn show_toolchain_env_not_installed() {
845846
});
846847
}
847848

849+
#[test]
850+
fn show_active_toolchain() {
851+
setup(&|config| {
852+
expect_ok(config, &["rustup", "default", "nightly"]);
853+
expect_ok_ex(
854+
config,
855+
&["rustup", "show", "active-toolchain"],
856+
for_host!(
857+
r"nightly-{0}
858+
"
859+
),
860+
r"",
861+
);
862+
});
863+
}
864+
865+
#[test]
866+
fn show_active_toolchain_none() {
867+
setup(&|config| {
868+
expect_ok_ex(
869+
config,
870+
&["rustup", "show", "active-toolchain"],
871+
r"",
872+
r"",
873+
);
874+
});
875+
}
876+
848877
// #846
849878
#[test]
850879
fn set_default_host() {
@@ -1390,3 +1419,19 @@ fn file_override_with_target_info() {
13901419
);
13911420
});
13921421
}
1422+
1423+
#[test]
1424+
fn docs_with_path() {
1425+
setup(&|config| {
1426+
expect_ok(config, &["rustup", "default", "stable"]);
1427+
1428+
let mut cmd = clitools::cmd(config, "rustup", &["doc", "--path"]);
1429+
clitools::env(config, &mut cmd);
1430+
let out = cmd.output().unwrap();
1431+
1432+
let stdout = String::from_utf8(out.stdout).unwrap();
1433+
let path = format!("share{}doc{}rust{}html",
1434+
MAIN_SEPARATOR, MAIN_SEPARATOR, MAIN_SEPARATOR);
1435+
assert!(stdout.contains(path.as_str()));
1436+
});
1437+
}

0 commit comments

Comments
 (0)