summaryrefslogtreecommitdiffstats
path: root/third_party/rust/new_debug_unreachable
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/new_debug_unreachable')
-rw-r--r--third_party/rust/new_debug_unreachable/.cargo-checksum.json1
-rw-r--r--third_party/rust/new_debug_unreachable/Cargo.toml27
-rw-r--r--third_party/rust/new_debug_unreachable/LICENSE-MIT25
-rw-r--r--third_party/rust/new_debug_unreachable/README.md27
-rw-r--r--third_party/rust/new_debug_unreachable/examples/simple.rs11
-rw-r--r--third_party/rust/new_debug_unreachable/src/lib.rs24
-rw-r--r--third_party/rust/new_debug_unreachable/tests/check.rs9
7 files changed, 124 insertions, 0 deletions
diff --git a/third_party/rust/new_debug_unreachable/.cargo-checksum.json b/third_party/rust/new_debug_unreachable/.cargo-checksum.json
new file mode 100644
index 0000000000..9b19767db6
--- /dev/null
+++ b/third_party/rust/new_debug_unreachable/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.toml":"4081c443d3318411bec6bf1dd8284b7ef4eb39994ca2be66292f0bce6ffae9f6","LICENSE-MIT":"f7715d38a3fa1b4ac97c5729740752505a39cb92ee83ab5b102aeb5eaa7cdea4","README.md":"36ffe300159d4ce4c8224969723606312770117a0a25fbcb3534922c8248b0e9","examples/simple.rs":"c05b124bdad67bfe9e48998bff6a7c6a8789e7f7c9fb3f318f8028a68ef944ed","src/lib.rs":"08a58847b86729b9b2a4eb1125457fc5e76206f9f86a014c1ba26ce6e3f0ebac","tests/check.rs":"ac8691f78269e1cb0cd010150e707f5ea5df14055883f0ee5a5b55a686c5b8de"},"package":"0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4"} \ No newline at end of file
diff --git a/third_party/rust/new_debug_unreachable/Cargo.toml b/third_party/rust/new_debug_unreachable/Cargo.toml
new file mode 100644
index 0000000000..47473eec48
--- /dev/null
+++ b/third_party/rust/new_debug_unreachable/Cargo.toml
@@ -0,0 +1,27 @@
+# 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 believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+name = "new_debug_unreachable"
+version = "1.0.1"
+authors = ["Matt Brubeck <mbrubeck@limpet.net>", "Jonathan Reem <jonathan.reem@gmail.com>"]
+description = "panic in debug, intrinsics::unreachable() in release (fork of debug_unreachable)"
+documentation = "https://docs.rs/new_debug_unreachable"
+readme = "README.md"
+license = "MIT"
+repository = "https://github.com/mbrubeck/rust-debug-unreachable"
+
+[lib]
+name = "debug_unreachable"
+path = "src/lib.rs"
+[dependencies.unreachable]
+version = "1.0"
diff --git a/third_party/rust/new_debug_unreachable/LICENSE-MIT b/third_party/rust/new_debug_unreachable/LICENSE-MIT
new file mode 100644
index 0000000000..c8e0f5ec7a
--- /dev/null
+++ b/third_party/rust/new_debug_unreachable/LICENSE-MIT
@@ -0,0 +1,25 @@
+Copyright (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.
diff --git a/third_party/rust/new_debug_unreachable/README.md b/third_party/rust/new_debug_unreachable/README.md
new file mode 100644
index 0000000000..28ff761b14
--- /dev/null
+++ b/third_party/rust/new_debug_unreachable/README.md
@@ -0,0 +1,27 @@
+# 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"
+```
+
+## 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
diff --git a/third_party/rust/new_debug_unreachable/examples/simple.rs b/third_party/rust/new_debug_unreachable/examples/simple.rs
new file mode 100644
index 0000000000..3da34c149e
--- /dev/null
+++ b/third_party/rust/new_debug_unreachable/examples/simple.rs
@@ -0,0 +1,11 @@
+#[macro_use]
+extern crate debug_unreachable;
+
+fn main() {
+ if 0 > 100 {
+ // Can't happen!
+ unsafe { debug_unreachable!() }
+ } else {
+ println!("Good, 0 <= 100.");
+ }
+}
diff --git a/third_party/rust/new_debug_unreachable/src/lib.rs b/third_party/rust/new_debug_unreachable/src/lib.rs
new file mode 100644
index 0000000000..ebe89ef925
--- /dev/null
+++ b/third_party/rust/new_debug_unreachable/src/lib.rs
@@ -0,0 +1,24 @@
+#![deny(missing_docs, warnings)]
+
+#![no_std]
+
+//! `panic!()` in debug builds, optimization hint in release.
+
+extern crate unreachable;
+
+#[doc(hidden)]
+pub use unreachable::unreachable as __unreachable;
+
+#[macro_export]
+/// `panic!()` in debug builds, optimization hint in release.
+macro_rules! debug_unreachable {
+ () => { debug_unreachable!("entered unreachable code") };
+ ($e:expr) => {
+ if cfg!(debug_assertions) {
+ panic!($e);
+ } else {
+ $crate::__unreachable()
+ }
+ }
+}
+
diff --git a/third_party/rust/new_debug_unreachable/tests/check.rs b/third_party/rust/new_debug_unreachable/tests/check.rs
new file mode 100644
index 0000000000..f47ee2da50
--- /dev/null
+++ b/third_party/rust/new_debug_unreachable/tests/check.rs
@@ -0,0 +1,9 @@
+#[macro_use]
+extern crate debug_unreachable;
+
+#[test]
+#[should_panic]
+fn explodes_in_debug() {
+ unsafe { debug_unreachable!() }
+}
+