diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 3ae45c1f6b..9d1325571d 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -402,6 +402,10 @@ struct UpdateOpts { /// Install toolchains that require an emulator. See https://github.com/rust-lang/rustup/wiki/Non-host-toolchains #[arg(long)] force_non_host: bool, + + /// Set the installed toolchain as the override for the current directory + #[arg(long)] + r#override: bool, } #[derive(Debug, Default, Args)] @@ -946,6 +950,7 @@ async fn update( let self_update_mode = SelfUpdateMode::from_cfg(cfg)?; let should_self_update = !opts.no_self_update; let force_non_host = opts.force_non_host; + let set_override = opts.r#override; cfg.profile_override = opts.profile; let cfg = &cfg; @@ -1003,6 +1008,11 @@ async fn update( PackageUpdate::Toolchain(desc.clone()), Ok(status.clone()), )?; + + if set_override { + cfg.make_override(&cfg.current_dir, &desc.clone().into())?; + } + if cfg.get_default()?.is_none() && matches!(status, UpdateStatus::Installed) { cfg.set_default(Some(&desc.into()))?; } diff --git a/tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg b/tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg index fada49de25..f996dc9902 100644 --- a/tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg +++ b/tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg @@ -1,4 +1,4 @@ - +