Switch to autocfg from rustc_version

This commit is contained in:
Gilad Naaman 2020-03-16 19:07:13 +02:00
parent 73f5dddc90
commit 449841d45d
2 changed files with 5 additions and 11 deletions

View File

@ -10,7 +10,7 @@ keywords = ["mem", "offset", "offset_of", "offsetof"]
categories = ["no-std"]
[build-dependencies]
rustc_version = "0.2.3"
autocfg = "1"
[dev-dependencies]
doc-comment = "0.3"

View File

@ -1,20 +1,14 @@
extern crate rustc_version;
use rustc_version::{version, Version};
fn main() {
let version = version().unwrap();
// Assert we haven't travelled back in time
assert!(version.major >= 1);
let ac = autocfg::new();
// Check for a minimum version for a few features
if version >= Version::from((1, 31, 0)) {
if ac.probe_rustc_version(1, 31) {
println!("cargo:rustc-cfg=allow_clippy");
}
if version >= Version::from((1, 36, 0)) {
if ac.probe_rustc_version(1, 36) {
println!("cargo:rustc-cfg=maybe_uninit");
}
if version >= Version::from((1, 40, 0)) {
if ac.probe_rustc_version(1, 40) {
println!("cargo:rustc-cfg=doctests");
}
}