Skip to content

Commit 3f42796

Browse files
committed
rename macro to make it less palatable for use outside stdlib.
1 parent 20c7d0f commit 3f42796

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/libcore/macros.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// SNAP 5520801
1212
#[cfg(stage0)]
1313
#[macro_export]
14-
macro_rules! ensure_not_fmt_string_literal {
15-
($name:expr, $e:expr) => { $e }
14+
macro_rules! __unstable_rustc_ensure_not_fmt_string_literal {
15+
($name:expr, $e:expr) => { ((), $e) }
1616
}
1717

1818
/// Entry point of task panic, for details, see std::macros
@@ -23,7 +23,8 @@ macro_rules! panic {
2323
);
2424
($msg:expr) => ({
2525
static _MSG_FILE_LINE: (&'static str, &'static str, u32) =
26-
(ensure_not_fmt_string_literal!("panic!", $msg), file!(), line!());
26+
(__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg).1,
27+
file!(), line!());
2728
::core::panicking::panic(&_MSG_FILE_LINE)
2829
});
2930
($fmt:expr, $($arg:tt)*) => ({

src/libstd/macros.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
// SNAP 5520801
2020
#[cfg(stage0)]
2121
#[macro_export]
22-
macro_rules! ensure_not_fmt_string_literal {
23-
($name:expr, $e:expr) => { $e }
22+
macro_rules! __unstable_rustc_ensure_not_fmt_string_literal {
23+
($name:expr, $e:expr) => { ((), $e) }
2424
}
2525

2626
/// The entry point for panic of Rust tasks.
@@ -51,7 +51,8 @@ macro_rules! panic {
5151
panic!("explicit panic")
5252
});
5353
($msg:expr) => ({
54-
$crate::rt::begin_unwind(ensure_not_fmt_string_literal!("panic!", $msg), {
54+
$crate::rt::begin_unwind(
55+
__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg).1, {
5556
// static requires less code at runtime, more constant data
5657
static _FILE_LINE: (&'static str, usize) = (file!(), line!() as usize);
5758
&_FILE_LINE
@@ -97,11 +98,12 @@ macro_rules! panic {
9798
panic!("explicit panic")
9899
});
99100
($msg:expr) => ({
100-
$crate::rt::begin_unwind($msg, {
101-
// static requires less code at runtime, more constant data
102-
static _FILE_LINE: (&'static str, u32) = (file!(), line!());
103-
&_FILE_LINE
104-
})
101+
$crate::rt::begin_unwind(
102+
__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg), {
103+
// static requires less code at runtime, more constant data
104+
static _FILE_LINE: (&'static str, u32) = (file!(), line!());
105+
&_FILE_LINE
106+
})
105107
});
106108
($fmt:expr, $($arg:tt)+) => ({
107109
$crate::rt::begin_unwind_fmt(format_args!($fmt, $($arg)+), {

src/libsyntax/ext/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>)
458458
syntax_expanders.insert(intern("format_args"),
459459
// format_args uses `unstable` things internally.
460460
NormalTT(Box::new(ext::format::expand_format_args), None, true));
461-
syntax_expanders.insert(intern("ensure_not_fmt_string_literal"),
461+
syntax_expanders.insert(intern("__unstable_rustc_ensure_not_fmt_string_literal"),
462462
builtin_normal_expander(
463463
ext::format::ensure_not_fmt_string_literal));
464464
syntax_expanders.insert(intern("env"),

0 commit comments

Comments
 (0)