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
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ license = "Apache-2.0 WITH LLVM-exception"
repository = "https://github.com/bytecodealliance/target-lexicon"
edition = "2018"
include = ["Cargo.toml", "README.md", "LICENSE", "build.rs", "src/**/*.rs"]
rust-version = "1.81"

[dependencies]
serde = { version = "1.0", optional = true }
Expand All @@ -29,6 +30,3 @@ arch_z80 = []

[badges]
maintenance = { status = "passively-maintained" }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(feature, values("rust_1_40", "cargo-clippy"))'] }
26 changes: 0 additions & 26 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,6 @@ fn main() {
Triple::from_str(&target).unwrap_or_else(|_| panic!("Invalid target name: '{}'", target));
let out = File::create(out_dir.join("host.rs")).expect("error creating host.rs");
write_host_rs(out, triple).expect("error writing host.rs");
if using_1_40() {
println!("cargo:rustc-cfg=feature=\"rust_1_40\"");
}
}

fn using_1_40() -> bool {
match (|| {
let rustc = env::var_os("RUSTC").unwrap();
let output = Command::new(rustc).arg("--version").output().ok()?;
let stdout = if output.status.success() {
output.stdout
} else {
return None;
};
std::str::from_utf8(&stdout)
.ok()?
.split(' ')
.nth(1)?
.split('.')
.nth(1)?
.parse::<i32>()
.ok()
})() {
Some(version) => version >= 40,
None => true, // assume we're using an up-to-date compiler
}
}

fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/data_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Size {
///
/// See also https://en.cppreference.com/w/c/language/arithmetic_types
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
pub enum CDataModel {
/// The data model used most commonly on Win16. `long` and `pointer` are 32 bits.
LP32,
Expand Down
3 changes: 1 addition & 2 deletions src/parse_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ impl fmt::Display for ParseError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for ParseError {}
impl core::error::Error for ParseError {}

@bjorn3 bjorn3 Jun 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The MSRV is 1.34. core::error::Error doesn't exist until 1.81. You may need to add something like

target-lexicon/build.rs

Lines 55 to 57 in 2d53442

if using_1_40() {
println!("cargo:rustc-cfg=feature=\"rust_1_40\"");
}

30 changes: 15 additions & 15 deletions src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use core::str::FromStr;

/// The "architecture" field, which in some cases also specifies a specific
/// subarchitecture.
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Architecture {
Expand Down Expand Up @@ -60,7 +60,7 @@ pub enum Architecture {
Z80(Z80Architecture),
}

#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum ArmArchitecture {
Expand Down Expand Up @@ -110,7 +110,7 @@ pub enum ArmArchitecture {
Thumbv8mMain,
}

#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Aarch64Architecture {
Expand All @@ -123,7 +123,7 @@ pub enum Aarch64Architecture {
Arm64_32,
}

// #[cfg_attr(feature = "rust_1_40", non_exhaustive)]
// #[non_exhaustive]
// #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
// #[allow(missing_docs)]
// pub enum ArmFpu {
Expand Down Expand Up @@ -401,7 +401,7 @@ impl Aarch64Architecture {
}
}

#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum CleverArchitecture {
Expand All @@ -422,7 +422,7 @@ impl CleverArchitecture {
}

/// An enum for all 32-bit RISC-V architectures.
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Riscv32Architecture {
Expand Down Expand Up @@ -455,7 +455,7 @@ impl Riscv32Architecture {
}

/// An enum for all 64-bit RISC-V architectures.
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Riscv64Architecture {
Expand All @@ -480,7 +480,7 @@ impl Riscv64Architecture {
}

/// An enum for all 32-bit x86 architectures.
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum X86_32Architecture {
Expand All @@ -503,7 +503,7 @@ impl X86_32Architecture {
}

/// An enum for all 32-bit MIPS architectures (not just "MIPS32").
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Mips32Architecture {
Expand All @@ -528,7 +528,7 @@ impl Mips32Architecture {
}

/// An enum for all 64-bit MIPS architectures (not just "MIPS64").
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Mips64Architecture {
Expand All @@ -553,7 +553,7 @@ impl Mips64Architecture {
}

#[cfg(feature = "arch_z80")]
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Z80Architecture {
Expand Down Expand Up @@ -624,7 +624,7 @@ impl Hash for CustomVendor {

/// The "vendor" field, which in practice is little more than an arbitrary
/// modifier.
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Vendor {
Expand Down Expand Up @@ -699,7 +699,7 @@ pub struct DeploymentTarget {
/// LLVM's Apple triples may optionally include the [deployment target].
///
/// [deployment target]: DeploymentTarget
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum OperatingSystem {
Expand Down Expand Up @@ -845,7 +845,7 @@ impl OperatingSystem {
/// The "environment" field, which specifies an ABI environment on top of the
/// operating system. In many configurations, this field is omitted, and the
/// environment is implied by the operating system.
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Environment {
Expand Down Expand Up @@ -933,7 +933,7 @@ impl Environment {

/// The "binary format" field, which is usually omitted, and the binary format
/// is implied by the other fields.
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum BinaryFormat {
Expand Down
2 changes: 1 addition & 1 deletion src/triple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl PointerWidth {

/// The calling convention, which specifies things like which registers are
/// used for passing arguments, which registers are callee-saved, and so on.
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum CallingConvention {
/// "System V", which is used on most Unix-like platfoms. Note that the
Expand Down
Loading