From 949443eff640ede205502547ea04a4dd350b255f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 12 May 2014 21:23:13 -0700 Subject: [PATCH] core: Allow using failure outside of libcore Due to our excellent macro hygiene, this involves having a global path and a hidden module in libcore itself. --- src/libcore/failure.rs | 2 +- src/libcore/lib.rs | 7 +++++-- src/libcore/macros.rs | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs index 2296e663033c..8a28f7b13928 100644 --- a/src/libcore/failure.rs +++ b/src/libcore/failure.rs @@ -10,7 +10,7 @@ //! Failure support for libcore -#![allow(dead_code)] +#![allow(dead_code, missing_doc)] #[cfg(not(test))] use str::raw::c_str_to_static_slice; diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 490e499db37b..4eab7e9d45d3 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -106,6 +106,7 @@ pub mod atomics; pub mod bool; pub mod cell; pub mod char; +pub mod failure; pub mod finally; pub mod iter; pub mod option; @@ -118,13 +119,15 @@ pub mod tuple; #[cfg(stage0, not(test))] pub mod owned; -mod failure; - // FIXME: this module should not exist. Once owned allocations are no longer a // language type, this module can move outside to the owned allocation // crate. mod should_not_exist; +mod core { + pub use failure; +} + mod std { pub use clone; pub use cmp; diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 50d5cd81ba00..69be68a34a13 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -17,7 +17,7 @@ macro_rules! fail( fail!("explicit failure") ); ($msg:expr) => ( - ::failure::begin_unwind($msg, file!(), line!()) + ::core::failure::begin_unwind($msg, file!(), line!()) ); )