Skip to content
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
6 changes: 3 additions & 3 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,15 @@ pub(crate) fn ignorable_error(
pub(crate) fn check_non_host_toolchain(
toolchain: String,
host_arch: &TargetTuple,
target_triple: &TargetTuple,
target_tuple: &TargetTuple,
force_non_host: bool,
) -> Result<()> {
if force_non_host || host_arch.can_run(target_triple)? {
if force_non_host || host_arch.can_run(target_tuple)? {
return Ok(());
}
Err(RustupError::ToolchainIncompatible {
toolchain,
target_triple: target_triple.clone(),
target_tuple: target_tuple.clone(),
}
.into())
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub(crate) fn toolchain_help() -> String {
{PLACEHOLDER}<versioned> = <major.minor>|<major.minor.patch>{PLACEHOLDER:#}
{PLACEHOLDER}<prerelease> = beta[.<number>]{PLACEHOLDER:#}
{PLACEHOLDER}<date> = YYYY-MM-DD{PLACEHOLDER:#}
{PLACEHOLDER}<host> = <target-triple>{PLACEHOLDER:#}
{PLACEHOLDER}<host> = <target-tuple>{PLACEHOLDER:#}
'channel' is a named release channel, a major and minor version
number such as `1.42`, or a fully specified version number, such
Expand Down
2 changes: 1 addition & 1 deletion src/cli/proxy_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub async fn main(arg0: &str, current_dir: PathBuf, process: &Process) -> Result
let (toolchain, source) = cfg
.local_toolchain(match toolchain {
Some(name) => Some((
name.resolve(&cfg.get_default_host_triple()?)?,
name.resolve(&cfg.default_host_tuple()?)?,
ActiveSource::CommandLine,
)),
None => None,
Expand Down
20 changes: 10 additions & 10 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ pub async fn main(
},
RustupSubcmd::Set { subcmd } => match subcmd {
SetSubcmd::DefaultHost { host_triple } => cfg
.set_default_host_triple(host_triple)
.set_default_host_tuple(host_triple)
.map(|_| ExitCode::SUCCESS),
SetSubcmd::Profile { profile_name } => {
cfg.set_profile(profile_name).map(|_| ExitCode::SUCCESS)
Expand Down Expand Up @@ -787,7 +787,7 @@ async fn default_(
cfg.set_default(Some(&toolchain_name.into()))?;
}
MaybeResolvableToolchainName::Some(ResolvableToolchainName::Official(toolchain)) => {
let desc = toolchain.resolve(&cfg.get_default_host_triple()?)?;
let desc = toolchain.resolve(&cfg.default_host_tuple()?)?;
let status = cfg
.ensure_installed(&desc, vec![], vec![], None, force_non_host, true)
.await?
Expand Down Expand Up @@ -992,7 +992,7 @@ async fn update(
force_non_host,
)?;
}
let desc = name.resolve(&cfg.get_default_host_triple()?)?;
let desc = name.resolve(&cfg.default_host_tuple()?)?;

let components = opts.component.iter().map(|s| &**s).collect::<Vec<_>>();
let targets = opts.target.iter().map(|s| &**s).collect::<Vec<_>>();
Expand Down Expand Up @@ -1060,7 +1060,7 @@ async fn run(
command: Vec<String>,
install: bool,
) -> Result<ExitStatus> {
let toolchain = toolchain.resolve(&cfg.get_default_host_triple()?)?;
let toolchain = toolchain.resolve(&cfg.default_host_tuple()?)?;
let toolchain = Toolchain::from_local(toolchain, install, cfg).await?;
let cmd = toolchain.command(&command[0])?;
command::run_command_for_dir(cmd, &command[0], &command[1..])
Expand All @@ -1074,7 +1074,7 @@ async fn which(
let (toolchain, _) = cfg
.local_toolchain(match toolchain {
Some(name) => Some((
name.resolve(&cfg.get_default_host_triple()?)?.into(),
name.resolve(&cfg.default_host_tuple()?)?.into(),
ActiveSource::CommandLine, // From --toolchain option
)),
None => None,
Expand Down Expand Up @@ -1108,14 +1108,14 @@ async fn which(
async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<ExitCode> {
common::warn_if_host_is_emulated(cfg.process);

// Print host triple
// Print host tuple
{
let t = cfg.process.stdout();
let mut t = t.lock();
writeln!(
t,
"{HEADER}Default host: {HEADER:#}{}",
cfg.get_default_host_triple()?
cfg.default_host_tuple()?
)?;
}

Expand Down Expand Up @@ -1387,7 +1387,7 @@ async fn target_remove(

for target in targets {
let target = TargetTuple::new(target);
let default_target = cfg.get_default_host_triple()?;
let default_target = cfg.default_host_tuple()?;
if target == default_target {
warn!(
"removing the default host target; proc-macros and build scripts might no longer build"
Expand Down Expand Up @@ -1562,7 +1562,7 @@ async fn toolchain_remove(cfg: &mut Cfg<'_>, opts: UninstallOpts) -> Result<Exit
.map(|(it, _)| it);

for toolchain_name in &opts.toolchain {
let toolchain_name = toolchain_name.resolve(&cfg.get_default_host_triple()?)?;
let toolchain_name = toolchain_name.resolve(&cfg.default_host_tuple()?)?;

if active_toolchain
.as_ref()
Expand Down Expand Up @@ -1591,7 +1591,7 @@ async fn override_add(
toolchain: ResolvableToolchainName,
path: Option<&Path>,
) -> Result<ExitCode> {
let toolchain_name = toolchain.resolve(&cfg.get_default_host_triple()?)?;
let toolchain_name = toolchain.resolve(&cfg.default_host_tuple()?)?;
match Toolchain::new(cfg, (&toolchain_name).into()) {
Ok(_) => {}
Err(e @ RustupError::ToolchainNotInstalled { .. }) => match &toolchain_name {
Expand Down
13 changes: 6 additions & 7 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ impl InstallOpts<'_> {
if let Some(default_host_tuple) = &default_host_tuple {
// Set host tuple now as it will affect resolution of toolchain_str
info!("setting default host tuple to {}", default_host_tuple);
cfg.set_default_host_triple(default_host_tuple.to_owned())?;
cfg.set_default_host_tuple(default_host_tuple.to_owned())?;
} else {
info!("default host tuple is {}", cfg.get_default_host_triple()?);
info!("default host tuple is {}", cfg.default_host_tuple()?);
}

let user_specified_something = default_toolchain.is_some()
Expand Down Expand Up @@ -164,7 +164,7 @@ impl InstallOpts<'_> {
MaybeOfficialToolchainName::None => unreachable!(),
MaybeOfficialToolchainName::Some(n) => n,
};
Some(toolchain_name.resolve(&cfg.get_default_host_triple()?)?)
Some(toolchain_name.resolve(&cfg.default_host_tuple()?)?)
}
None => match cfg.get_default()? {
// Default is installable
Expand All @@ -174,7 +174,7 @@ impl InstallOpts<'_> {
None => Some(
"stable"
.parse::<PartialToolchainDesc>()?
.resolve(&cfg.get_default_host_triple()?)?,
.resolve(&cfg.default_host_tuple()?)?,
),
},
})
Expand Down Expand Up @@ -736,8 +736,7 @@ fn check_existence_of_settings_file(cfg: &Cfg<'_>) -> Result<()> {
};
warn!("it looks like you have an existing rustup settings file at:");
warn!("{}", settings_file_path.display());
let inferred =
PartialToolchainDesc::from_str("stable")?.resolve(&cfg.get_default_host_triple()?)?;
let inferred = PartialToolchainDesc::from_str("stable")?.resolve(&cfg.default_host_tuple()?)?;
if default_toolchain != inferred.to_string() {
warn!("rustup will install the default toolchain as specified in the settings file,");
warn!("instead of the one inferred from the default host tuple.");
Expand Down Expand Up @@ -1479,7 +1478,7 @@ mod tests {
"stable"
.parse::<PartialToolchainDesc>()
.unwrap()
.resolve(&cfg.get_default_host_triple().unwrap())
.resolve(&cfg.default_host_tuple().unwrap())
.unwrap(),
opts.install(&mut cfg)
.unwrap() // result
Expand Down
27 changes: 13 additions & 14 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl OverrideCfg {
fn from_file(cfg: &Cfg<'_>, file: OverrideFile) -> Result<Self> {
let toolchain_name = match (file.toolchain.channel, file.toolchain.path) {
(Some(name), None) => {
ResolvableToolchainName::try_from(name)?.resolve(&cfg.get_default_host_triple()?)?
ResolvableToolchainName::try_from(name)?.resolve(&cfg.default_host_tuple()?)?
}
(None, Some(path)) => {
if file.toolchain.targets.is_some()
Expand Down Expand Up @@ -288,9 +288,8 @@ impl<'a> Cfg<'a> {
let update_hash_dir = rustup_dir.join("update-hashes");
let download_dir = rustup_dir.join("downloads");

// Figure out get_default_host_triple before Config is populated
let default_host_triple =
settings_file.with(|s| Ok(get_default_host_triple(s, process)))?;
// Figure out default_host_tuple before Config is populated
let default_host_triple = settings_file.with(|s| Ok(default_host_tuple(s, process)))?;
// Environment override
let env_override = match process.var_opt("RUSTUP_TOOLCHAIN")? {
Some(tc) => {
Expand Down Expand Up @@ -323,7 +322,7 @@ impl<'a> Cfg<'a> {
// For now, that means simply checking that 'stable' can resolve
// for the current configuration.
ResolvableToolchainName::try_from("stable")?.resolve(
&cfg.get_default_host_triple()
&cfg.default_host_tuple()
.context("Unable parse configuration")?,
)?;

Expand Down Expand Up @@ -483,7 +482,7 @@ impl<'a> Cfg<'a> {
.map(|(desc, source)| {
anyhow::Ok((
LocalToolchainName::Named(ToolchainName::Official(
desc.resolve(&self.get_default_host_triple()?)?,
desc.resolve(&self.default_host_tuple()?)?,
)),
source,
))
Expand Down Expand Up @@ -529,7 +528,7 @@ impl<'a> Cfg<'a> {
let override_config: Option<(OverrideCfg, ActiveSource)> =
// First check +toolchain override from the command line
if let Some(name) = &self.toolchain_override {
let override_config = name.resolve(&self.get_default_host_triple()?)?.into();
let override_config = name.resolve(&self.default_host_tuple()?)?.into();
Some((override_config, ActiveSource::CommandLine))
}
// Then check the RUSTUP_TOOLCHAIN environment variable
Expand Down Expand Up @@ -574,7 +573,7 @@ impl<'a> Cfg<'a> {
// have an unresolved name. I'm just preserving pre-existing
// behaviour by choosing ResolvableToolchainName here.
let toolchain_name = ResolvableToolchainName::try_from(name)?
.resolve(&get_default_host_triple(settings, self.process))?;
.resolve(&default_host_tuple(settings, self.process))?;
let override_cfg = toolchain_name.into();
return Ok(Some((override_cfg, source)));
}
Expand Down Expand Up @@ -632,7 +631,7 @@ impl<'a> Cfg<'a> {
toolchain_file.display()
)
})?;
let default_host_triple = get_default_host_triple(settings, self.process);
let default_host_triple = default_host_tuple(settings, self.process);
// Do not permit architecture/os selection in channels as
// these are host specific and toolchain files are portable.
if let ResolvableToolchainName::Official(name) = &toolchain_name
Expand Down Expand Up @@ -839,7 +838,7 @@ impl<'a> Cfg<'a> {
toolchain_maybe_str
.map(ResolvableToolchainName::try_from)
.transpose()?
.map(|t| t.resolve(&self.get_default_host_triple()?))
.map(|t| t.resolve(&self.default_host_tuple()?))
.transpose()
}

Expand Down Expand Up @@ -896,7 +895,7 @@ impl<'a> Cfg<'a> {
})
}

pub(crate) fn set_default_host_triple(&self, host_triple: String) -> Result<()> {
pub(crate) fn set_default_host_tuple(&self, host_triple: String) -> Result<()> {
// Ensure that the provided host_triple is capable of resolving
// against the 'stable' toolchain. This provides early errors
// if the supplied triple is insufficient / bad.
Expand All @@ -909,9 +908,9 @@ impl<'a> Cfg<'a> {
}

#[tracing::instrument(level = "trace", skip_all)]
pub(crate) fn get_default_host_triple(&self) -> Result<TargetTuple> {
pub(crate) fn default_host_tuple(&self) -> Result<TargetTuple> {
self.settings_file
.with(|s| Ok(get_default_host_triple(s, self.process)))
.with(|s| Ok(default_host_tuple(s, self.process)))
}

/// The path on disk of any concrete toolchain
Expand Down Expand Up @@ -980,7 +979,7 @@ impl Debug for Cfg<'_> {
}
}

fn get_default_host_triple(s: &Settings, process: &Process) -> TargetTuple {
fn default_host_tuple(s: &Settings, process: &Process) -> TargetTuple {
s.default_host_triple
.as_ref()
.map(TargetTuple::new)
Expand Down
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ pub enum RustupError {
RunningCommand { name: OsString },
#[error(
"toolchain '{toolchain}' may not be able to run on this system\n\
note: to build software for that platform, try `rustup target add {target_triple}` instead\n\
note: to build software for that platform, try `rustup target add {target_tuple}` instead\n\
note: add the `--force-non-host` flag to install the toolchain anyway"
)]
ToolchainIncompatible {
toolchain: String,
target_triple: TargetTuple,
target_tuple: TargetTuple,
},
#[error("toolchain '{0}' is not installable")]
ToolchainNotInstallable(String),
Expand Down
2 changes: 1 addition & 1 deletion src/test/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ async fn setup_test_state(test_dist_dir: TempDir) -> (TempDir, Config) {
hard_link(&rustup_path, rls_path).unwrap();
hard_link(&rustup_path, rust_lldb_path).unwrap();

// Make sure the host triple matches the build triple. Otherwise testing a 32-bit build of
// Make sure the host tuple matches the build tuple. Otherwise testing a 32-bit build of
// rustup on a 64-bit machine will fail, because the tests do not have the host detection
// functionality built in.
config
Expand Down
Loading
Loading