Skip to content

Fix conversion from PartialTargetTriple to TargetTriple #3467

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

Closed
Changes from 1 commit
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
17 changes: 7 additions & 10 deletions src/dist/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,13 @@ impl TargetTriple {
impl std::convert::TryFrom<PartialTargetTriple> for TargetTriple {
type Error = &'static str;
fn try_from(value: PartialTargetTriple) -> std::result::Result<Self, Self::Error> {
if value.arch.is_some() && value.os.is_some() && value.env.is_some() {
Ok(Self(format!(
"{}-{}-{}",
value.arch.unwrap(),
value.os.unwrap(),
value.env.unwrap()
)))
} else {
Err("Incomplete / bad target triple")
}
let arch = value.arch.ok_or("Incomplete / bad target triple")?;
let os = value.os.ok_or("Incomplete / bad target triple")?;
let triple = match value.env {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiny style nit: I would spell this Ok(Self(match value.env { .. })) directly, which avoids a low-value single use binding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, willing to do so.

Some(env) => format!("{}-{}-{}", arch, os, env),
None => format!("{}-{}", arch, os),
};
Ok(Self(triple))
}
}

Expand Down