require rustc 1.28.0
This commit is contained in:
parent
c2504d67ab
commit
f043eacbfa
|
@ -107,6 +107,8 @@ You also need to declare it by adding this to your crate root (usually
|
|||
extern crate fixed;
|
||||
```
|
||||
|
||||
The *fixed* crate requires rustc version 1.28.0 or later.
|
||||
|
||||
## License
|
||||
|
||||
This crate is free software: you can redistribute it and/or modify it
|
||||
|
|
30
build.rs
30
build.rs
|
@ -24,22 +24,39 @@ fn main() {
|
|||
};
|
||||
env.check_feature(
|
||||
"repr_transparent",
|
||||
Optional(false),
|
||||
TRY_REPR_TRANSPARENT,
|
||||
Some("repr_transparent"),
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct Optional(bool);
|
||||
|
||||
impl Environment {
|
||||
fn check_feature(&self, name: &str, contents: &str, nightly_features: Option<&str>) {
|
||||
// 1. If optional feature is availble (both with and without flag), output:
|
||||
// cargo:rustc-cfg=<name>
|
||||
// 2. If feature is available with flag (both optional and not), output:
|
||||
// cargo:rustc-cfg_nightly=<name>
|
||||
// 3. If non-optional feature is not available, panic.
|
||||
fn check_feature(
|
||||
&self,
|
||||
name: &str,
|
||||
optional: Optional,
|
||||
contents: &str,
|
||||
nightly_features: Option<&str>,
|
||||
) {
|
||||
let try_dir = self.out_dir.join(format!("try_{}", name));
|
||||
let filename = format!("try_{}.rs", name);
|
||||
create_dir_or_panic(&try_dir);
|
||||
println!("$ cd {:?}", try_dir);
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum Iteration {
|
||||
Stable,
|
||||
Unstable,
|
||||
}
|
||||
let mut found = false;
|
||||
for i in &[Iteration::Stable, Iteration::Unstable] {
|
||||
let s;
|
||||
let file_contents = match *i {
|
||||
|
@ -61,15 +78,20 @@ impl Environment {
|
|||
.status()
|
||||
.unwrap_or_else(|_| panic!("Unable to execute: {:?}", cmd));
|
||||
if status.success() {
|
||||
println!("cargo:rustc-cfg={}", name);
|
||||
if let Iteration::Unstable = *i {
|
||||
if !optional.0 {
|
||||
println!("cargo:rustc-cfg={}", name);
|
||||
}
|
||||
if *i == Iteration::Unstable {
|
||||
println!("cargo:rustc-cfg=nightly_{}", name);
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
remove_dir_or_panic(&try_dir);
|
||||
if !found && !optional.0 {
|
||||
panic!("essential feature not supported by compiler: {}", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ You also need to declare it by adding this to your crate root (usually
|
|||
extern crate fixed;
|
||||
```
|
||||
|
||||
The *fixed* crate requires rustc version 1.28.0 or later.
|
||||
|
||||
## License
|
||||
|
||||
This crate is free software: you can redistribute it and/or modify it
|
||||
|
@ -306,7 +308,7 @@ macro_rules! fixed {
|
|||
"[const generics]: https://github.com/rust-lang/rust/issues/44580\n",
|
||||
"[typenum crate]: https://crates.io/crates/typenum\n"
|
||||
),
|
||||
#[cfg_attr(repr_transparent, repr(transparent))]
|
||||
#[repr(transparent)]
|
||||
pub struct $Fixed<Frac: Unsigned>(($Inner, PhantomData<Frac>));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue