new_debug_unreachable-1.0.6/.cargo_vcs_info.json0000644000000001360000000000100153300ustar { "git": { "sha1": "4b3fa6e0b6d728ed2018690e087a440dd29e7d06" }, "path_in_vcs": "" }new_debug_unreachable-1.0.6/.gitignore000064400000000000000000000002071046102023000161070ustar 00000000000000.DS_Store *~ *# *.o *.so *.swp *.dylib *.dSYM *.dll *.rlib *.dummy *.exe *-test /doc/ /target/ /examples/* !/examples/*.rs Cargo.lock new_debug_unreachable-1.0.6/.travis.yml000064400000000000000000000000171046102023000162270ustar 00000000000000language: rust new_debug_unreachable-1.0.6/Cargo.lock0000644000000002450000000000100133040ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "new_debug_unreachable" version = "1.0.6" new_debug_unreachable-1.0.6/Cargo.toml0000644000000020400000000000100133220ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "new_debug_unreachable" version = "1.0.6" authors = [ "Matt Brubeck ", "Jonathan Reem ", ] description = "panic in debug, intrinsics::unreachable() in release (fork of debug_unreachable)" documentation = "https://docs.rs/new_debug_unreachable" readme = "README.md" keywords = [ "optimization", "macro", ] categories = [ "rust-patterns", "no-std", ] license = "MIT" repository = "https://github.com/mbrubeck/rust-debug-unreachable" [lib] name = "debug_unreachable" path = "src/lib.rs" new_debug_unreachable-1.0.6/Cargo.toml.orig000064400000000000000000000010331046102023000170040ustar 00000000000000[package] edition = "2021" name = "new_debug_unreachable" version = "1.0.6" authors = ["Matt Brubeck ", "Jonathan Reem "] repository = "https://github.com/mbrubeck/rust-debug-unreachable" description = "panic in debug, intrinsics::unreachable() in release (fork of debug_unreachable)" documentation = "https://docs.rs/new_debug_unreachable" license = "MIT" keywords = ["optimization", "macro"] categories = ["rust-patterns", "no-std"] [lib] name = "debug_unreachable" path = "src/lib.rs" new_debug_unreachable-1.0.6/LICENSE-MIT000064400000000000000000000020411046102023000155510ustar 00000000000000Copyright (c) 2015 Jonathan Reem Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. new_debug_unreachable-1.0.6/README.md000064400000000000000000000015611046102023000154020ustar 00000000000000# new_debug_unreachable > unreachable!() in debug, std::intrinsics::unreachable() in release. This is a fork of [`debug_unreachable`](https://crates.io/crates/debug_unreachable). ## [Documentation](https://docs.rs/new_debug_unreachable) ## Usage Use the crates.io repository; add this to your `Cargo.toml` along with the rest of your dependencies: ```toml [dependencies] new_debug_unreachable = "1.0" ``` In your Rust code, the library name is still `debug_unreachable`: ```rust use debug_unreachable::debug_unreachable; fn main() { if 0 > 100 { // Can't happen! unsafe { debug_unreachable!() } } else { println!("Good, 0 <= 100."); } } ``` ## Author [Jonathan Reem](https://medium.com/@jreem) is the original author of debug-unreachable. [Matt Brubeck](https://limpet.net/mbrubeck/) is the maintainer of this fork. ## License MIT new_debug_unreachable-1.0.6/examples/simple.rs000064400000000000000000000003031046102023000175710ustar 00000000000000use debug_unreachable::debug_unreachable; fn main() { if 0 > 100 { // Can't happen! unsafe { debug_unreachable!() } } else { println!("Good, 0 <= 100."); } } new_debug_unreachable-1.0.6/src/lib.rs000064400000000000000000000015571046102023000160330ustar 00000000000000#![no_std] //! `panic!()` in debug builds, optimization hint in release. #[doc(hidden)] pub mod _internal { pub use core::hint::unreachable_unchecked; } #[macro_export] /// `panic!()` in debug builds, optimization hint in release. /// /// This is equivalent to [`core::unreachable`] in debug builds, /// and [`core::hint::unreachable_unchecked`] in release builds. /// /// Example: /// /// ``` /// use debug_unreachable::debug_unreachable; /// /// if 0 > 100 { /// // Can't happen! /// unsafe { debug_unreachable!() } /// } else { /// println!("Good, 0 <= 100."); /// } /// ``` macro_rules! debug_unreachable { () => { debug_unreachable!("entered unreachable code") }; ($e:expr) => { if cfg!(debug_assertions) { unreachable!($e) } else { $crate::_internal::unreachable_unchecked() } }; } new_debug_unreachable-1.0.6/tests/check.rs000064400000000000000000000002361046102023000167060ustar 00000000000000#[test] #[should_panic] #[cfg(debug_assertions)] fn explodes_in_debug() { use debug_unreachable::debug_unreachable; unsafe { debug_unreachable!() } }