Skip to content

Commit 5575da2

Browse files
committed
remove attempts to encode macro's instability from implementation.
1 parent 4efe144 commit 5575da2

File tree

3 files changed

+5
-38
lines changed

3 files changed

+5
-38
lines changed

src/libcore/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#[cfg(stage0)]
1313
#[macro_export]
1414
macro_rules! __unstable_rustc_ensure_not_fmt_string_literal {
15-
($name:expr, $e:expr) => { ((), $e) }
15+
($name:expr, $e:expr) => { $e }
1616
}
1717

1818
/// Entry point of task panic, for details, see std::macros
@@ -23,7 +23,7 @@ macro_rules! panic {
2323
);
2424
($msg:expr) => ({
2525
static _MSG_FILE_LINE: (&'static str, &'static str, u32) =
26-
(__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg).1,
26+
(__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg),
2727
file!(), line!());
2828
::core::panicking::panic(&_MSG_FILE_LINE)
2929
});

src/libstd/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#[macro_export]
2222
#[allow_internal_unstable]
2323
macro_rules! __unstable_rustc_ensure_not_fmt_string_literal {
24-
($name:expr, $e:expr) => { ((), $e) }
24+
($name:expr, $e:expr) => { $e }
2525
}
2626

2727
/// The entry point for panic of Rust tasks.
@@ -53,7 +53,7 @@ macro_rules! panic {
5353
});
5454
($msg:expr) => ({
5555
$crate::rt::begin_unwind(
56-
__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg).1, {
56+
__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg), {
5757
// static requires less code at runtime, more constant data
5858
static _FILE_LINE: (&'static str, usize) = (file!(), line!() as usize);
5959
&_FILE_LINE
@@ -100,7 +100,7 @@ macro_rules! panic {
100100
});
101101
($msg:expr) => ({
102102
$crate::rt::begin_unwind(
103-
__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg).1, {
103+
__unstable_rustc_ensure_not_fmt_string_literal!("unary `panic!`", $msg), {
104104
// static requires less code at runtime, more constant data
105105
static _FILE_LINE: (&'static str, u32) = (file!(), line!());
106106
&_FILE_LINE

src/libsyntax/ext/format.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -701,39 +701,6 @@ pub fn ensure_not_fmt_string_literal<'cx>(cx: &'cx mut ExtCtxt,
701701
}
702702
};
703703

704-
let unstable_marker = cx.expr_path(cx.path_global(sp, vec![
705-
cx.ident_of_std("core"),
706-
cx.ident_of("fmt"),
707-
cx.ident_of("ENSURE_NOT_FMT_STRING_LITERAL_IS_UNSTABLE")]));
708-
709-
// Total hack: We do not (yet) have hygienic-marking of stabilty.
710-
// Thus an unstable macro (like `ensure_not_fmt_string!`) can leak
711-
// through another macro (like `panic!`), where the latter is just
712-
// using the former as an implementation detail.
713-
//
714-
// The `#[allow_internal_unstable]` system does not suffice to
715-
// address this; it explicitly (as described on Issue #22899)
716-
// disallows the use of unstable functionality via a helper macro
717-
// like `ensure_not_fmt_string!`, by design.
718-
//
719-
// So, the hack: the `ensure_not_fmt_string!` macro has just one
720-
// stable client: `panic!`. So we give `panic!` a backdoor: we
721-
// allow its name literal string to give it stable access. Any
722-
// other argument that is passed in will cause us to emit the
723-
// unstable-marker, which will then be checked against the enabled
724-
// feature-set.
725-
//
726-
// This, combined with the awkward actual name of the unstable
727-
// macro (hint: the real name is far more awkward than the one
728-
// given in this comment) should suffice to ensure that people do
729-
// not accidentally commit to using it.
730-
let marker = if name == "unary `panic!`" {
731-
cx.expr_tuple(sp, vec![]) // i.e. `()`
732-
} else {
733-
unstable_marker
734-
};
735-
let expr = cx.expr_tuple(sp, vec![marker, expr]);
736-
737704
MacEager::expr(expr)
738705
}
739706

0 commit comments

Comments
 (0)