Skip to content

Commit 949443e

Browse files
committed
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.
1 parent 82a8a5e commit 949443e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/libcore/failure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! Failure support for libcore
1212
13-
#![allow(dead_code)]
13+
#![allow(dead_code, missing_doc)]
1414

1515
#[cfg(not(test))]
1616
use str::raw::c_str_to_static_slice;

src/libcore/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub mod atomics;
106106
pub mod bool;
107107
pub mod cell;
108108
pub mod char;
109+
pub mod failure;
109110
pub mod finally;
110111
pub mod iter;
111112
pub mod option;
@@ -118,13 +119,15 @@ pub mod tuple;
118119
#[cfg(stage0, not(test))]
119120
pub mod owned;
120121

121-
mod failure;
122-
123122
// FIXME: this module should not exist. Once owned allocations are no longer a
124123
// language type, this module can move outside to the owned allocation
125124
// crate.
126125
mod should_not_exist;
127126

127+
mod core {
128+
pub use failure;
129+
}
130+
128131
mod std {
129132
pub use clone;
130133
pub use cmp;

src/libcore/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! fail(
1717
fail!("explicit failure")
1818
);
1919
($msg:expr) => (
20-
::failure::begin_unwind($msg, file!(), line!())
20+
::core::failure::begin_unwind($msg, file!(), line!())
2121
);
2222
)
2323

0 commit comments

Comments
 (0)