Skip to content

Commit

Permalink
📝 add cfg nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
Xudong-Huang committed Jun 4, 2024
1 parent 405959b commit 32717ca
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions benches/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(nightly)]
#![feature(test)]
#![allow(deprecated)]
extern crate generator;
Expand Down
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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");
}
}
18 changes: 6 additions & 12 deletions src/detail/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ fn catch_unwind_filter<F: FnOnce() -> 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::<Error>() {
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::<Error>() {
return;
}
prev_hook(info);
}));
Expand All @@ -39,12 +36,9 @@ pub fn gen_init_impl(_: usize, f: *mut usize) -> ! {
};

fn check_err(cause: Box<dyn Any + Send + 'static>) {
if let Some(e) = cause.downcast_ref::<Error>() {
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::<Error>() {
return;
}

error!("set panic inside generator");
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion src/stack/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down

0 comments on commit 32717ca

Please sign in to comment.