diff --git a/Cargo.toml b/Cargo.toml index 7b69deb..7c59940 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,9 +36,7 @@ libc = "0.2.100" log = "0.4" cfg-if = "1.0.0" - [build-dependencies] -cc = "1.0" rustversion = "1.0" # release build diff --git a/benches/lib.rs b/benches/lib.rs index 37651e9..58b45f2 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -1,3 +1,4 @@ +#![cfg(nightly)] #![feature(test)] #![allow(deprecated)] extern crate generator; diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..120f911 --- /dev/null +++ b/build.rs @@ -0,0 +1,12 @@ +#[rustversion::nightly] +const NIGHTLY: bool = true; + +#[rustversion::not(nightly)] +const NIGHTLY: bool = false; + +fn main() { + println!("cargo::rustc-check-cfg=cfg(nightly)"); + if NIGHTLY { + println!("cargo::rustc-cfg=nightly"); + } +} diff --git a/src/detail/gen.rs b/src/detail/gen.rs index 8c9ae64..d8a6d68 100644 --- a/src/detail/gen.rs +++ b/src/detail/gen.rs @@ -12,12 +12,9 @@ fn catch_unwind_filter R + panic::UnwindSafe, R>(f: F) -> std::th INIT.call_once(|| { let prev_hook = panic::take_hook(); panic::set_hook(Box::new(move |info| { - if let Some(e) = info.payload().downcast_ref::() { - match e { - // this is not an error at all, ignore it - Error::Cancel | Error::Done => return, - _ => {} - } + // this is not an error at all, ignore it + if let Some(Error::Cancel | Error::Done) = info.payload().downcast_ref::() { + return; } prev_hook(info); })); @@ -39,12 +36,9 @@ pub fn gen_init_impl(_: usize, f: *mut usize) -> ! { }; fn check_err(cause: Box) { - if let Some(e) = cause.downcast_ref::() { - match e { - // this is not an error at all, ignore it - Error::Cancel | Error::Done => return, - _ => {} - } + // this is not an error at all, ignore it + if let Some(Error::Cancel | Error::Done) = cause.downcast_ref::() { + return; } error!("set panic inside generator"); diff --git a/src/lib.rs b/src/lib.rs index 3fdcdd2..f724d5c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,8 +4,7 @@ //! #![cfg_attr(nightly, feature(thread_local))] -#![cfg_attr(test, deny(warnings))] -#![deny(missing_docs)] +#![deny(warnings, missing_docs)] #![allow(deprecated)] #[macro_use] diff --git a/src/stack/windows.rs b/src/stack/windows.rs index a0435e2..e2f1f4d 100644 --- a/src/stack/windows.rs +++ b/src/stack/windows.rs @@ -3,7 +3,6 @@ use std::mem; use std::os::raw::c_void; use std::ptr; use std::sync::atomic::{AtomicUsize, Ordering}; -use std::usize; use windows::Win32::System::Memory::*; use windows::Win32::System::SystemInformation::*;