diff --git a/src/config.rs b/src/config.rs index 50a2ec1fde4..495b9f2b5d2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1046,6 +1046,8 @@ enum ParseMode { mod tests { use rustup_macros::unit_test as test; + use crate::{cli::common::set_globals, utils::raw}; + use super::*; #[test] @@ -1248,4 +1250,27 @@ channel = nightly Ok(OverrideFileConfigError::Parsing) )); } + + /// Checks that `rust-toolchain.toml` configs can be overridden by ` +`. + /// See: + #[test] + fn find_override_config_with_toolchain_override() { + let cwd = crate::test::test_dir().unwrap(); + let toolchain_file = cwd.path().join("rust-toolchain.toml"); + raw::write_file( + &toolchain_file, + r#" + [toolchain] + channel = "nightly" + components = [ "rls" ] + "#, + ) + .unwrap(); + + let mut cfg = set_globals(true, false).unwrap(); + cfg.toolchain_override = Some("beta".try_into().unwrap()); + + let found_override = cfg.find_override_config(cwd.path()).unwrap(); + assert!(dbg!(found_override).is_none()); + } }