From 9f45261a075f0ecac8928e40fb37ca650319bd46 Mon Sep 17 00:00:00 2001 From: Xudong Huang Date: Tue, 17 Aug 2021 15:11:09 +0800 Subject: [PATCH] :pencil: use panic_any --- src/gen_impl.rs | 2 +- src/lib.rs | 1 - src/rt.rs | 2 +- src/scope.rs | 2 +- src/yield_.rs | 6 +++--- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gen_impl.rs b/src/gen_impl.rs index a407ed6..5eaac3b 100644 --- a/src/gen_impl.rs +++ b/src/gen_impl.rs @@ -536,7 +536,7 @@ impl<'a, A, T> Drop for GeneratorImpl<'a, A, T> { // set_stack_size::(used_stack); } else { error!("stack overflow detected!"); - panic!(Error::StackErr); + std::panic::panic_any(Error::StackErr); } } } diff --git a/src/lib.rs b/src/lib.rs index 5b922f1..3ff0115 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,6 @@ #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] #![allow(deprecated)] -#![allow(non_fmt_panic)] #[macro_use] extern crate log; diff --git a/src/rt.rs b/src/rt.rs index 46f585b..692f63d 100644 --- a/src/rt.rs +++ b/src/rt.rs @@ -271,7 +271,7 @@ fn type_error(msg: &str) -> ! { { error!("{}", msg); } - panic!(Error::TypeErr) + std::panic::panic_any(Error::TypeErr) } /// check the current context if it's generator diff --git a/src/scope.rs b/src/scope.rs index 98547b2..18fec83 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -43,7 +43,7 @@ impl<'a, A, T> Scope<'a, A, T> { // here we just panic to exit the func if context._ref != 1 { - panic!(Error::Cancel); + std::panic::panic_any(Error::Cancel); } } diff --git a/src/yield_.rs b/src/yield_.rs index f82be13..0fa5e6d 100644 --- a/src/yield_.rs +++ b/src/yield_.rs @@ -60,7 +60,7 @@ fn raw_yield(env: &ContextStack, context: &mut Context, v: T) { // here we just panic to exit the func if context._ref != 1 { - panic!(Error::Cancel); + std::panic::panic_any(Error::Cancel); } } @@ -88,7 +88,7 @@ fn raw_get_yield(context: &mut Context) -> Option { if !context.is_generator() { { error!("get yield from none generator context"); - panic!(Error::ContextErr); + std::panic::panic_any(Error::ContextErr); } } @@ -140,7 +140,7 @@ pub fn co_yield_with(v: T) { // here we just panic to exit the func if context._ref != 1 { - panic!(Error::Cancel); + std::panic::panic_any(Error::Cancel); } context.co_set_ret(v);