Skip to content

Commit 577bf51

Browse files
authored
Merge pull request #3312 from hi-rustin/rustin-patch-master-to-stable
Merge master to stable
2 parents 9ac66b5 + e724717 commit 577bf51

11 files changed

+91
-68
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ strsim = "0.10"
6767
tar = "0.4.26"
6868
tempfile.workspace = true
6969
# FIXME(issue #1818, #1826, and friends)
70-
term = "=0.7.0"
70+
term = "=0.5.1"
7171
thiserror.workspace = true
7272
threadpool = "1"
7373
toml = "0.5"

doc/src/network-proxies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ http_proxy=proxy.example.com:1080` (and likewise for HTTPS). If you are
3838
getting an SSL `unknown protocol` error from `rustup` via `libcurl` but the
3939
command-line `curl` command works fine, this may be the problem.
4040

41-
[curlman]: https://curl.haxx.se/docs/manpage.html
41+
[curlman]: https://curl.se/docs/manpage.html#:~:text=Environment,-The%20environment%20variables
4242
[cmd]: https://en.wikipedia.org/wiki/Cmd.exe
4343
[ps]: https://en.wikipedia.org/wiki/PowerShell

src/cli/rustup_mode.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ use crate::utils::utils;
3030
use crate::Notification;
3131
use crate::{command, Cfg, ComponentStatus, Toolchain};
3232

33+
const TOOLCHAIN_OVERRIDE_ERROR: &str =
34+
"To override the toolchain using the 'rustup +toolchain' syntax, \
35+
make sure to prefix the toolchain override with a '+'";
36+
3337
fn handle_epipe(res: Result<utils::ExitCode>) -> Result<utils::ExitCode> {
3438
match res {
3539
Err(e) => {
@@ -110,6 +114,10 @@ pub fn main() -> Result<utils::ExitCode> {
110114
write!(process().stdout().lock(), "{err}")?;
111115
return Ok(utils::ExitCode(1));
112116
}
117+
if err.kind() == ValueValidation && err.to_string().contains(TOOLCHAIN_OVERRIDE_ERROR) {
118+
write!(process().stderr().lock(), "{err}")?;
119+
return Ok(utils::ExitCode(1));
120+
}
113121
Err(err)
114122
}
115123
}?;
@@ -226,7 +234,7 @@ pub(crate) fn cli() -> Command<'static> {
226234
.about("The Rust toolchain installer")
227235
.after_help(RUSTUP_HELP)
228236
.global_setting(AppSettings::DeriveDisplayOrder)
229-
.arg_required_else_help(true)
237+
.setting(AppSettings::SubcommandRequiredElseHelp)
230238
.arg(
231239
verbose_arg("Enable verbose output"),
232240
)
@@ -245,7 +253,9 @@ pub(crate) fn cli() -> Command<'static> {
245253
if s.starts_with('+') {
246254
Ok(s.to_owned())
247255
} else {
248-
Err("Toolchain overrides must begin with '+'".to_owned())
256+
Err(format!(
257+
"\"{s}\" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. {TOOLCHAIN_OVERRIDE_ERROR}"
258+
))
249259
}
250260
}),
251261
)
@@ -369,8 +379,7 @@ pub(crate) fn cli() -> Command<'static> {
369379
Command::new("toolchain")
370380
.about("Modify or query the installed toolchains")
371381
.after_help(TOOLCHAIN_HELP)
372-
.subcommand_required(true)
373-
.arg_required_else_help(true)
382+
.setting(AppSettings::SubcommandRequiredElseHelp)
374383
.subcommand(
375384
Command::new("list")
376385
.about("List installed toolchains")
@@ -475,8 +484,7 @@ pub(crate) fn cli() -> Command<'static> {
475484
.subcommand(
476485
Command::new("target")
477486
.about("Modify a toolchain's supported targets")
478-
.subcommand_required(true)
479-
.arg_required_else_help(true)
487+
.setting(AppSettings::SubcommandRequiredElseHelp)
480488
.subcommand(
481489
Command::new("list")
482490
.about("List installed and available targets")
@@ -536,8 +544,7 @@ pub(crate) fn cli() -> Command<'static> {
536544
.subcommand(
537545
Command::new("component")
538546
.about("Modify a toolchain's installed components")
539-
.subcommand_required(true)
540-
.arg_required_else_help(true)
547+
.setting(AppSettings::SubcommandRequiredElseHelp)
541548
.subcommand(
542549
Command::new("list")
543550
.about("List installed and available components")
@@ -593,8 +600,7 @@ pub(crate) fn cli() -> Command<'static> {
593600
Command::new("override")
594601
.about("Modify directory toolchain overrides")
595602
.after_help(OVERRIDE_HELP)
596-
.subcommand_required(true)
597-
.arg_required_else_help(true)
603+
.setting(AppSettings::SubcommandRequiredElseHelp)
598604
.subcommand(
599605
Command::new("list").about("List directory toolchain overrides"),
600606
)
@@ -722,8 +728,7 @@ pub(crate) fn cli() -> Command<'static> {
722728
.subcommand(
723729
Command::new("self")
724730
.about("Modify the rustup installation")
725-
.subcommand_required(true)
726-
.arg_required_else_help(true)
731+
.setting(AppSettings::SubcommandRequiredElseHelp)
727732
.subcommand(Command::new("update").about("Download and install updates to rustup"))
728733
.subcommand(
729734
Command::new("uninstall")
@@ -737,8 +742,7 @@ pub(crate) fn cli() -> Command<'static> {
737742
.subcommand(
738743
Command::new("set")
739744
.about("Alter rustup settings")
740-
.subcommand_required(true)
741-
.arg_required_else_help(true)
745+
.setting(AppSettings::SubcommandRequiredElseHelp)
742746
.subcommand(
743747
Command::new("default-host")
744748
.about("The triple used to identify toolchains when not specified")

src/utils/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,8 @@ where
622622
OperationResult::Retry(e)
623623
}
624624
#[cfg(target_os = "linux")]
625-
io::ErrorKind::Other
626-
if process().var_os("RUSTUP_PERMIT_COPY_RENAME").is_some()
627-
&& Some(EXDEV) == e.raw_os_error() =>
625+
_ if process().var_os("RUSTUP_PERMIT_COPY_RENAME").is_some()
626+
&& Some(EXDEV) == e.raw_os_error() =>
628627
{
629628
match copy_and_delete(name, src, dest, notify_handler) {
630629
Ok(()) => OperationResult::Ok(()),

tests/suite/cli-ui/rustup/rustup_help_cmd_stdout.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rustup [..]
66
The Rust toolchain installer
77
88
USAGE:
9-
rustup[EXE] [OPTIONS] [+toolchain] [SUBCOMMAND]
9+
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>
1010
1111
ARGS:
1212
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override

tests/suite/cli-ui/rustup/rustup_help_flag_stdout.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rustup [..]
66
The Rust toolchain installer
77
88
USAGE:
9-
rustup[EXE] [OPTIONS] [+toolchain] [SUBCOMMAND]
9+
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>
1010
1111
ARGS:
1212
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
bin.name = "rustup"
2+
args = ["-v"]
3+
status.code = 1
4+
stdout = """
5+
rustup [..]
6+
The Rust toolchain installer
7+
8+
USAGE:
9+
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>
10+
11+
ARGS:
12+
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
13+
14+
OPTIONS:
15+
-v, --verbose Enable verbose output
16+
-q, --quiet Disable progress output
17+
-h, --help Print help information
18+
-V, --version Print version information
19+
20+
SUBCOMMANDS:
21+
show Show the active and installed toolchains or profiles
22+
update Update Rust toolchains and rustup
23+
check Check for updates to Rust toolchains and rustup
24+
default Set the default toolchain
25+
toolchain Modify or query the installed toolchains
26+
target Modify a toolchain's supported targets
27+
component Modify a toolchain's installed components
28+
override Modify directory toolchain overrides
29+
run Run a command with an environment configured for a given toolchain
30+
which Display which binary will be run for a given command
31+
doc Open the documentation for the current toolchain
32+
...
33+
self Modify the rustup installation
34+
set Alter rustup settings
35+
completions Generate tab-completion scripts for your shell
36+
help Print this message or the help of the given subcommand(s)
37+
38+
DISCUSSION:
39+
Rustup installs The Rust Programming Language from the official
40+
release channels, enabling you to easily switch between stable,
41+
beta, and nightly compilers and keep them updated. It makes
42+
cross-compiling simpler with binary builds of the standard library
43+
for common platforms.
44+
45+
If you are new to Rust consider running `rustup doc --book` to
46+
learn Rust.
47+
"""
48+
stderr = ""
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bin.name = "rustup"
2+
args = ["random"]
3+
status.code = 1
4+
stdout = ""
5+
stderr = """
6+
error: Invalid value \"random\" for '<+toolchain>': \"random\" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. To override the toolchain using the 'rustup +toolchain' syntax, make sure to prefix the toolchain override with a '+'
7+
8+
For more information try --help
9+
"""

tests/suite/cli_misc.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,6 @@ fn override_by_toolchain_on_the_command_line() {
944944
&["rustup", "+foo", "which", "rustc"],
945945
"toolchain 'foo' is not installed",
946946
);
947-
config.expect_err(
948-
&["rustup", "@stable", "which", "rustc"],
949-
r#"Invalid value "@stable" for '<+toolchain>': Toolchain overrides must begin with '+'"#,
950-
);
951947
config.expect_stderr_ok(
952948
&["rustup", "+stable", "set", "profile", "minimal"],
953949
"profile set to 'minimal'",

www/website_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"headers": {
3-
"Strict-Transport-Security": "max-age=63072000; includeSubDomains",
3+
"Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
44
"X-Content-Type-Options": "nosniff",
55
"X-Frame-Options": "DENY",
66
"X-XSS-Protection": "1; mode=block",

0 commit comments

Comments
 (0)