Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ async fn default_(
MaybeResolvableToolchainName::Some(ResolvableToolchainName::Official(toolchain)) => {
let desc = toolchain.resolve(&cfg.get_default_host_triple()?)?;
let status = cfg
.ensure_installed(&desc, vec![], vec![], None, force_non_host, true)
.ensure_installed(&desc, vec![], vec![], None, force_non_host, true, false)
Copy link
Contributor Author

@cachebag cachebag Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djc I think I might be confused with this one- how do you suggest I handle this? I don't know if it's best here to add an attribute, ignoring it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean. Do you have more context on what the problem is/why you're not sure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djc I'm sorry, I think I get it..So if I understand correctly, I'm supposed to remove the extra parameter completely from ensure_installed and only set skip_std on DistOptions in the caller before installation?

.await?
.0;

Expand Down
42 changes: 41 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct ToolchainSection {
components: Option<Vec<String>>,
targets: Option<Vec<String>>,
profile: Option<String>,
skip_std: Option<bool>,
}

impl ToolchainSection {
Expand All @@ -64,6 +65,7 @@ impl ToolchainSection {
&& self.components.is_none()
&& self.targets.is_none()
&& self.path.is_none()
&& self.skip_std.is_none()
}
}

Expand Down Expand Up @@ -137,6 +139,7 @@ enum OverrideCfg {
components: Vec<String>,
targets: Vec<String>,
profile: Option<Profile>,
skip_std: bool,
},
}

Expand Down Expand Up @@ -180,6 +183,7 @@ impl OverrideCfg {
ToolchainName::Official(desc) => {
let components = file.toolchain.components.unwrap_or_default();
let targets = file.toolchain.targets.unwrap_or_default();

Self::Official {
toolchain: desc,
components,
Expand All @@ -190,6 +194,7 @@ impl OverrideCfg {
.as_deref()
.map(Profile::from_str)
.transpose()?,
skip_std: file.toolchain.skip_std.unwrap_or(false),
}
}
ToolchainName::Custom(name) => Self::Custom(name),
Expand All @@ -213,6 +218,7 @@ impl From<ToolchainName> for OverrideCfg {
components: vec![],
targets: vec![],
profile: None,
skip_std: false,
},
ToolchainName::Custom(name) => Self::Custom(name),
}
Expand Down Expand Up @@ -737,6 +743,7 @@ impl<'a> Cfg<'a> {
components,
targets,
profile,
skip_std,
} = override_config
{
self.ensure_installed(
Expand All @@ -746,6 +753,7 @@ impl<'a> Cfg<'a> {
profile,
force_non_host,
verbose,
skip_std,
)
.await?;
} else {
Expand All @@ -755,7 +763,7 @@ impl<'a> Cfg<'a> {
} else if let Some(toolchain) = self.get_default()? {
let source = ActiveSource::Default;
if let ToolchainName::Official(desc) = &toolchain {
self.ensure_installed(desc, vec![], vec![], None, force_non_host, verbose)
self.ensure_installed(desc, vec![], vec![], None, force_non_host, verbose, false)
.await?;
} else {
Toolchain::with_source(self, toolchain.clone().into(), &source)?;
Expand All @@ -777,6 +785,7 @@ impl<'a> Cfg<'a> {
profile: Option<Profile>,
force_non_host: bool,
verbose: bool,
skip_std: bool,
) -> Result<(UpdateStatus, Toolchain<'_>)> {
common::check_non_host_toolchain(
toolchain.to_string(),
Expand All @@ -800,6 +809,7 @@ impl<'a> Cfg<'a> {
false,
self,
)?;
options.skip_std = skip_std;

let (status, toolchain) = match DistributableToolchain::new(self, toolchain.clone()) {
Err(RustupError::ToolchainNotInstalled { .. }) => {
Expand Down Expand Up @@ -1030,6 +1040,7 @@ mod tests {
components: None,
targets: None,
profile: None,
skip_std: None,
}
}
);
Expand Down Expand Up @@ -1057,6 +1068,7 @@ profile = "default"
"thumbv2-none-eabi".into()
]),
profile: Some("default".into()),
skip_std: None,
}
}
);
Expand All @@ -1078,6 +1090,7 @@ channel = "nightly-2020-07-10"
components: None,
targets: None,
profile: None,
skip_std: None,
}
}
);
Expand All @@ -1099,6 +1112,7 @@ path = "foobar"
components: None,
targets: None,
profile: None,
skip_std: None,
}
}
);
Expand All @@ -1121,6 +1135,7 @@ components = []
components: Some(vec![]),
targets: None,
profile: None,
skip_std: None,
}
}
);
Expand All @@ -1143,6 +1158,7 @@ targets = []
components: None,
targets: Some(vec![]),
profile: None,
skip_std: None,
}
}
);
Expand All @@ -1164,6 +1180,7 @@ components = [ "rustfmt" ]
components: Some(vec!["rustfmt".into()]),
targets: None,
profile: None,
skip_std: None,
}
}
);
Expand Down Expand Up @@ -1216,4 +1233,27 @@ channel = nightly
Ok(OverrideFileConfigError::Parsing)
));
}

#[test]
fn parse_toml_toolchain_file_with_skip_std() {
let contents = r#"[toolchain]
channel = "nightly-2020-07-10"
skip_std = true
"#;

let result = Cfg::parse_override_file(contents, ParseMode::Both);
assert_eq!(
result.unwrap(),
OverrideFile {
toolchain: ToolchainSection {
channel: Some("nightly-2020-07-10".into()),
path: None,
components: None,
targets: None,
profile: None,
skip_std: Some(true),
}
}
);
}
}
21 changes: 18 additions & 3 deletions src/dist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,8 @@ pub(crate) struct DistOptions<'cfg, 'a> {
components: &'a [&'a str],
/// Extra targets to install from dist
targets: &'a [&'a str],
/// Flag to skip installation of rust-std
pub(super) skip_std: bool,
}

impl<'cfg, 'a> DistOptions<'cfg, 'a> {
Expand All @@ -923,6 +925,7 @@ impl<'cfg, 'a> DistOptions<'cfg, 'a> {
old_date_version: None,
components,
targets,
skip_std: false,
})
}

Expand Down Expand Up @@ -1034,6 +1037,7 @@ pub(crate) async fn update_from_dist(
opts.targets,
&mut fetched,
opts.cfg,
opts.skip_std,
)
.await;

Expand Down Expand Up @@ -1131,6 +1135,7 @@ async fn try_update_from_dist_(
targets: &[&str],
fetched: &mut String,
cfg: &Cfg<'_>,
skip_std: bool,
) -> Result<Option<String>> {
let toolchain_str = toolchain.to_string();
let manifestation = Manifestation::open(prefix.clone(), toolchain.target.clone())?;
Expand Down Expand Up @@ -1165,6 +1170,10 @@ async fn try_update_from_dist_(

let mut all_components: HashSet<Component> = profile_components.into_iter().collect();

if skip_std {
all_components.retain(|c| !c.short_name_in_manifest().starts_with("rust-std"));
}

let rust_package = m.get_package("rust")?;
let rust_target_package = rust_package.get_target(Some(&toolchain.target.clone()))?;

Expand All @@ -1188,9 +1197,15 @@ async fn try_update_from_dist_(
all_components.insert(component);
}

for &target in targets {
let triple = TargetTriple::new(target);
all_components.insert(Component::new("rust-std".to_string(), Some(triple), false));
if !skip_std {
for &target in targets {
let triple = TargetTriple::new(target);
all_components.insert(Component::new(
"rust-std".to_string(),
Some(triple),
false,
));
}
}

let mut explicit_add_components: Vec<_> = all_components.into_iter().collect();
Expand Down
Loading