Skip to content

Commit

Permalink
third pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 authored and sunfishcode committed Jul 2, 2020
1 parent b30799f commit 07e2cd1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ repository = "https://github.com/CraneStation/target-lexicon"
edition = "2018"

[features]
default = []
default = ["rust_1_40"]
# When enabled, use features that are only available with 1.40 or later.
rust_1_40 = []
std = []

[badges]
Expand Down
10 changes: 5 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
writeln!(out, "impl Architecture {{")?;
writeln!(out, " /// Return the architecture for the current host.")?;
writeln!(out, " pub const fn host() -> Self {{")?;
writeln!(out, " Self::{:?}", triple.architecture)?;
writeln!(out, " Architecture::{:?}", triple.architecture)?;
writeln!(out, " }}")?;
writeln!(out, "}}")?;
writeln!(out)?;

writeln!(out, "impl Vendor {{")?;
writeln!(out, " /// Return the vendor for the current host.")?;
writeln!(out, " pub const fn host() -> Self {{")?;
writeln!(out, " Self::{}", vendor_display(&triple.vendor))?;
writeln!(out, " Vendor::{}", vendor_display(&triple.vendor))?;
writeln!(out, " }}")?;
writeln!(out, "}}")?;
writeln!(out)?;
Expand All @@ -126,15 +126,15 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
" /// Return the operating system for the current host."
)?;
writeln!(out, " pub const fn host() -> Self {{")?;
writeln!(out, " Self::{:?}", triple.operating_system)?;
writeln!(out, " OperatingSystem::{:?}", triple.operating_system)?;
writeln!(out, " }}")?;
writeln!(out, "}}")?;
writeln!(out)?;

writeln!(out, "impl Environment {{")?;
writeln!(out, " /// Return the environment for the current host.")?;
writeln!(out, " pub const fn host() -> Self {{")?;
writeln!(out, " Self::{:?}", triple.environment)?;
writeln!(out, " Environment::{:?}", triple.environment)?;
writeln!(out, " }}")?;
writeln!(out, "}}")?;
writeln!(out)?;
Expand All @@ -145,7 +145,7 @@ fn write_host_rs(mut out: File, triple: Triple) -> io::Result<()> {
" /// Return the binary format for the current host."
)?;
writeln!(out, " pub const fn host() -> Self {{")?;
writeln!(out, " Self::{:?}", triple.binary_format)?;
writeln!(out, " BinaryFormat::{:?}", triple.binary_format)?;
writeln!(out, " }}")?;
writeln!(out, "}}")?;
writeln!(out)?;
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)]
#[non_exhaustive]
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
pub enum CDataModel {
/// The data model used most commonly on Win16. `long` and `pointer` are 32 bits.
LP32,
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
clippy::use_self,
)
)]
#![cfg_attr(not(feature = "std"), no_std)]

#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "std")]
extern crate std as alloc;
#[cfg(not(feature = "std"))]
extern crate alloc;

mod data_model;
Expand Down
26 changes: 13 additions & 13 deletions src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use core::str::FromStr;

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

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

#[non_exhaustive]
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Aarch64Architecture {
Aarch64,
Aarch64be,
}

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

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

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

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

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

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

/// The "vendor" field, which in practice is little more than an arbitrary
/// modifier.
#[non_exhaustive]
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Vendor {
Expand Down Expand Up @@ -405,7 +405,7 @@ pub enum Vendor {

/// The "operating system" field, which sometimes implies an environment, and
/// sometimes isn't an actual operating system.
#[non_exhaustive]
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum OperatingSystem {
Expand Down Expand Up @@ -442,7 +442,7 @@ pub enum 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.
#[non_exhaustive]
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum Environment {
Expand Down Expand Up @@ -473,7 +473,7 @@ pub enum Environment {

/// The "binary format" field, which is usually omitted, and the binary format
/// is implied by the other fields.
#[non_exhaustive]
#[cfg_attr(feature = "rust_1_40", non_exhaustive)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum BinaryFormat {
Expand Down

0 comments on commit 07e2cd1

Please sign in to comment.