Skip to content

Merge master to stable #3312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 9 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ strsim = "0.10"
tar = "0.4.26"
tempfile.workspace = true
# FIXME(issue #1818, #1826, and friends)
term = "=0.7.0"
term = "=0.5.1"
thiserror.workspace = true
threadpool = "1"
toml = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion doc/src/network-proxies.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ http_proxy=proxy.example.com:1080` (and likewise for HTTPS). If you are
getting an SSL `unknown protocol` error from `rustup` via `libcurl` but the
command-line `curl` command works fine, this may be the problem.

[curlman]: https://curl.haxx.se/docs/manpage.html
[curlman]: https://curl.se/docs/manpage.html#:~:text=Environment,-The%20environment%20variables
[cmd]: https://en.wikipedia.org/wiki/Cmd.exe
[ps]: https://en.wikipedia.org/wiki/PowerShell
32 changes: 18 additions & 14 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ use crate::utils::utils;
use crate::Notification;
use crate::{command, Cfg, ComponentStatus, Toolchain};

const TOOLCHAIN_OVERRIDE_ERROR: &str =
"To override the toolchain using the 'rustup +toolchain' syntax, \
make sure to prefix the toolchain override with a '+'";

fn handle_epipe(res: Result<utils::ExitCode>) -> Result<utils::ExitCode> {
match res {
Err(e) => {
Expand Down Expand Up @@ -110,6 +114,10 @@ pub fn main() -> Result<utils::ExitCode> {
write!(process().stdout().lock(), "{err}")?;
return Ok(utils::ExitCode(1));
}
if err.kind() == ValueValidation && err.to_string().contains(TOOLCHAIN_OVERRIDE_ERROR) {
write!(process().stderr().lock(), "{err}")?;
return Ok(utils::ExitCode(1));
}
Err(err)
}
}?;
Expand Down Expand Up @@ -226,7 +234,7 @@ pub(crate) fn cli() -> Command<'static> {
.about("The Rust toolchain installer")
.after_help(RUSTUP_HELP)
.global_setting(AppSettings::DeriveDisplayOrder)
.arg_required_else_help(true)
.setting(AppSettings::SubcommandRequiredElseHelp)
.arg(
verbose_arg("Enable verbose output"),
)
Expand All @@ -245,7 +253,9 @@ pub(crate) fn cli() -> Command<'static> {
if s.starts_with('+') {
Ok(s.to_owned())
} else {
Err("Toolchain overrides must begin with '+'".to_owned())
Err(format!(
"\"{s}\" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. {TOOLCHAIN_OVERRIDE_ERROR}"
))
}
}),
)
Expand Down Expand Up @@ -369,8 +379,7 @@ pub(crate) fn cli() -> Command<'static> {
Command::new("toolchain")
.about("Modify or query the installed toolchains")
.after_help(TOOLCHAIN_HELP)
.subcommand_required(true)
.arg_required_else_help(true)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(
Command::new("list")
.about("List installed toolchains")
Expand Down Expand Up @@ -475,8 +484,7 @@ pub(crate) fn cli() -> Command<'static> {
.subcommand(
Command::new("target")
.about("Modify a toolchain's supported targets")
.subcommand_required(true)
.arg_required_else_help(true)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(
Command::new("list")
.about("List installed and available targets")
Expand Down Expand Up @@ -536,8 +544,7 @@ pub(crate) fn cli() -> Command<'static> {
.subcommand(
Command::new("component")
.about("Modify a toolchain's installed components")
.subcommand_required(true)
.arg_required_else_help(true)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(
Command::new("list")
.about("List installed and available components")
Expand Down Expand Up @@ -593,8 +600,7 @@ pub(crate) fn cli() -> Command<'static> {
Command::new("override")
.about("Modify directory toolchain overrides")
.after_help(OVERRIDE_HELP)
.subcommand_required(true)
.arg_required_else_help(true)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(
Command::new("list").about("List directory toolchain overrides"),
)
Expand Down Expand Up @@ -722,8 +728,7 @@ pub(crate) fn cli() -> Command<'static> {
.subcommand(
Command::new("self")
.about("Modify the rustup installation")
.subcommand_required(true)
.arg_required_else_help(true)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(Command::new("update").about("Download and install updates to rustup"))
.subcommand(
Command::new("uninstall")
Expand All @@ -737,8 +742,7 @@ pub(crate) fn cli() -> Command<'static> {
.subcommand(
Command::new("set")
.about("Alter rustup settings")
.subcommand_required(true)
.arg_required_else_help(true)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(
Command::new("default-host")
.about("The triple used to identify toolchains when not specified")
Expand Down
5 changes: 2 additions & 3 deletions src/utils/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,8 @@ where
OperationResult::Retry(e)
}
#[cfg(target_os = "linux")]
io::ErrorKind::Other
if process().var_os("RUSTUP_PERMIT_COPY_RENAME").is_some()
&& Some(EXDEV) == e.raw_os_error() =>
_ if process().var_os("RUSTUP_PERMIT_COPY_RENAME").is_some()
&& Some(EXDEV) == e.raw_os_error() =>
{
match copy_and_delete(name, src, dest, notify_handler) {
Ok(()) => OperationResult::Ok(()),
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/cli-ui/rustup/rustup_help_cmd_stdout.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rustup [..]
The Rust toolchain installer

USAGE:
rustup[EXE] [OPTIONS] [+toolchain] [SUBCOMMAND]
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>

ARGS:
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/cli-ui/rustup/rustup_help_flag_stdout.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rustup [..]
The Rust toolchain installer

USAGE:
rustup[EXE] [OPTIONS] [+toolchain] [SUBCOMMAND]
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>

ARGS:
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
Expand Down
48 changes: 48 additions & 0 deletions tests/suite/cli-ui/rustup/rustup_only_options_stdout.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
bin.name = "rustup"
args = ["-v"]
status.code = 1
stdout = """
rustup [..]
The Rust toolchain installer

USAGE:
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>

ARGS:
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override

OPTIONS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-h, --help Print help information
-V, --version Print version information

SUBCOMMANDS:
show Show the active and installed toolchains or profiles
update Update Rust toolchains and rustup
check Check for updates to Rust toolchains and rustup
default Set the default toolchain
toolchain Modify or query the installed toolchains
target Modify a toolchain's supported targets
component Modify a toolchain's installed components
override Modify directory toolchain overrides
run Run a command with an environment configured for a given toolchain
which Display which binary will be run for a given command
doc Open the documentation for the current toolchain
...
self Modify the rustup installation
set Alter rustup settings
completions Generate tab-completion scripts for your shell
help Print this message or the help of the given subcommand(s)

DISCUSSION:
Rustup installs The Rust Programming Language from the official
release channels, enabling you to easily switch between stable,
beta, and nightly compilers and keep them updated. It makes
cross-compiling simpler with binary builds of the standard library
for common platforms.

If you are new to Rust consider running `rustup doc --book` to
learn Rust.
"""
stderr = ""
9 changes: 9 additions & 0 deletions tests/suite/cli-ui/rustup/rustup_unknown_arg_stdout.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bin.name = "rustup"
args = ["random"]
status.code = 1
stdout = ""
stderr = """
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 '+'

For more information try --help
"""
4 changes: 0 additions & 4 deletions tests/suite/cli_misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,10 +944,6 @@ fn override_by_toolchain_on_the_command_line() {
&["rustup", "+foo", "which", "rustc"],
"toolchain 'foo' is not installed",
);
config.expect_err(
&["rustup", "@stable", "which", "rustc"],
r#"Invalid value "@stable" for '<+toolchain>': Toolchain overrides must begin with '+'"#,
);
config.expect_stderr_ok(
&["rustup", "+stable", "set", "profile", "minimal"],
"profile set to 'minimal'",
Expand Down
2 changes: 1 addition & 1 deletion www/website_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"headers": {
"Strict-Transport-Security": "max-age=63072000; includeSubDomains",
"Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
"X-XSS-Protection": "1; mode=block",
Expand Down