switch to rustversion

This commit is contained in:
Andrea Fioraldi 2022-01-10 10:12:26 +01:00
parent 327ff98ea1
commit eed864eb36
3 changed files with 3 additions and 25 deletions

View File

@ -9,7 +9,6 @@ readme = "../README.md"
license = "MIT OR Apache-2.0"
keywords = ["fuzzing", "testing", "security"]
edition = "2021"
build = "build.rs"
[features]
default = ["std", "derive", "llmp_compression", "rand_trait", "fork"]
@ -43,6 +42,7 @@ num_cpus = "1.0" # cpu count, for llmp example
serial_test = "0.5"
[dependencies]
rustversion = "1.0"
tuple_list = { version = "0.1.3" }
hashbrown = { version = "0.11", features = ["serde", "ahash-compile-time-rng"], default-features=false } # A faster hashmap, nostd compatible
num-traits = { version = "0.2", default-features = false }

View File

@ -1,22 +0,0 @@
//! special handling to build and link libafl
use rustc_version::{version_meta, Channel};
#[allow(clippy::ptr_arg, clippy::upper_case_acronyms)]
fn main() {
// Set cfg flags depending on release channel
match version_meta().unwrap().channel {
Channel::Stable => {
println!("cargo:rustc-cfg=RUSTC_IS_STABLE");
}
Channel::Beta => {
println!("cargo:rustc-cfg=RUSTC_IS_BETA");
}
Channel::Nightly => {
println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY");
}
Channel::Dev => {
println!("cargo:rustc-cfg=RUSTC_IS_DEV");
}
}
}

View File

@ -6,7 +6,7 @@ use core::any::TypeId;
use xxhash_rust::xxh3::xxh3_64;
#[cfg(feature = "RUSTC_IS_NIGHTLY")]
#[rustversion::nightly]
/// From https://stackoverflow.com/a/60138532/7658998
const fn type_eq<T: ?Sized, U: ?Sized>() -> bool {
// Helper trait. `VALUE` is false, except for the specialization of the
@ -28,7 +28,7 @@ const fn type_eq<T: ?Sized, U: ?Sized>() -> bool {
<T as TypeEq<U>>::VALUE
}
#[cfg(not(feature = "RUSTC_IS_NIGHTLY"))]
#[rustversion::not(nightly)]
const fn type_eq<T: ?Sized, U: ?Sized>() -> bool {
// BEWARE! This is not unsafe, it is SUPER UNSAFE
true