Skip to content

Commit 00d5000

Browse files
author
Esteban Küber
committed
Gate format_args_nll behind feature flag
1 parent 83a8af5 commit 00d5000

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

src/libstd/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ pub mod builtin {
413413
///
414414
/// [`format_args`]: ../std/macro.format_args.html
415415
#[doc(hidden)]
416-
#[unstable(feature = "println_format_args", issue="0")]
416+
#[unstable(feature = "format_args_nl", issue="0")]
417417
#[macro_export]
418418
macro_rules! format_args_nl {
419419
($fmt:expr) => ({ /* compiler built-in */ });

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,7 @@ impl<'feat> ExpansionConfig<'feat> {
15921592
fn enable_trace_macros = trace_macros,
15931593
fn enable_allow_internal_unstable = allow_internal_unstable,
15941594
fn enable_custom_derive = custom_derive,
1595+
fn enable_format_args_nl = format_args_nl,
15951596
fn use_extern_macros_enabled = use_extern_macros,
15961597
fn macros_in_extern_enabled = macros_in_extern,
15971598
fn proc_macro_mod = proc_macro_mod,

src/libsyntax/feature_gate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ declare_features! (
129129
// rustc internal, for now:
130130
(active, intrinsics, "1.0.0", None, None),
131131
(active, lang_items, "1.0.0", None, None),
132+
(active, format_args_nl, "1.29.0", None, None),
132133

133134
(active, link_llvm_intrinsics, "1.0.0", Some(29602), None),
134135
(active, linkage, "1.0.0", Some(29603), None),
@@ -1327,6 +1328,9 @@ pub const EXPLAIN_LOG_SYNTAX: &'static str =
13271328
pub const EXPLAIN_CONCAT_IDENTS: &'static str =
13281329
"`concat_idents` is not stable enough for use and is subject to change";
13291330

1331+
pub const EXPLAIN_FORMAT_ARGS_NL: &'static str =
1332+
"`format_args_nl` is only for internal language use and is subject to change";
1333+
13301334
pub const EXPLAIN_TRACE_MACROS: &'static str =
13311335
"`trace_macros` is not stable enough for use and is subject to change";
13321336
pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &'static str =

src/libsyntax_ext/format.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use syntax::ast;
1717
use syntax::ext::base::*;
1818
use syntax::ext::base;
1919
use syntax::ext::build::AstBuilder;
20+
use syntax::feature_gate;
2021
use syntax::parse::token;
2122
use syntax::ptr::P;
2223
use syntax::symbol::Symbol;
@@ -693,6 +694,20 @@ pub fn expand_format_args_nl<'cx>(ecx: &'cx mut ExtCtxt,
693694
mut sp: Span,
694695
tts: &[tokenstream::TokenTree])
695696
-> Box<dyn base::MacResult + 'cx> {
697+
//if !ecx.ecfg.enable_allow_internal_unstable() {
698+
699+
// For some reason, the only one that actually works for `println` is the first check
700+
if !sp.allows_unstable() // the enclosing span is marked as `#[allow_insternal_unsable]`
701+
|| !ecx.ecfg.enable_allow_internal_unstable() // NOTE: when is this enabled?
702+
|| !ecx.ecfg.enable_format_args_nl() // enabled using `#[feature(format_args_nl]`
703+
{
704+
feature_gate::emit_feature_err(&ecx.parse_sess,
705+
"format_args_nl",
706+
sp,
707+
feature_gate::GateIssue::Language,
708+
feature_gate::EXPLAIN_FORMAT_ARGS_NL);
709+
return base::DummyResult::expr(sp);
710+
}
696711
sp = sp.apply_mark(ecx.current_expansion.mark);
697712
match parse_args(ecx, sp, tts) {
698713
Some((efmt, args, names)) => {

0 commit comments

Comments
 (0)