From 6fa0ff25bdc5aa5aae00dbe7c1cafc927b6806b6 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Sat, 19 Sep 2015 16:33:47 -0400 Subject: Feature-gate `#[no_debug]` and `#[omit_gdb_pretty_printer_section]` Closes #28091. --- src/libsyntax/feature_gate.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 1e9b244c57c..16d44e5046c 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -197,6 +197,12 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option, Status // allow overloading augmented assignment operations like `a += b` ("augmented_assignments", "1.5.0", None, Active), + + // allow `#[no_debug]` + ("no_debug", "1.5.0", None, Active), + + // allow `#[omit_gdb_pretty_printer_section]` + ("omit_gdb_pretty_printer_section", "1.5.0", None, Active), ]; // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -320,8 +326,13 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat ("link_section", Whitelisted, Ungated), ("no_builtins", Whitelisted, Ungated), ("no_mangle", Whitelisted, Ungated), - ("no_debug", Whitelisted, Ungated), - ("omit_gdb_pretty_printer_section", Whitelisted, Ungated), + ("no_debug", Whitelisted, Gated("no_debug", + "the `#[no_debug]` attribute \ + is an experimental feature")), + ("omit_gdb_pretty_printer_section", Whitelisted, Gated("omit_gdb_pretty_printer_section", + "the `#[omit_gdb_pretty_printer_section]` \ + attribute is just used for the Rust test \ + suite")), ("unsafe_no_drop_flag", Whitelisted, Gated("unsafe_no_drop_flag", "unsafe_no_drop_flag has unstable semantics \ and may be removed in the future")), -- cgit 1.4.1-3-g733a5 From 8aef16c2a5c175f7b4359122d7409765b09d6bf5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 20 Sep 2015 06:45:19 +0530 Subject: Move tts instead of cloning in expansion --- src/libsyntax/ext/expand.rs | 49 +++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1991124ae26..ffbb7edd385 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -684,15 +684,15 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool // logic as for expression-position macro invocations. pub fn expand_item_mac(it: P, fld: &mut MacroExpander) -> SmallVector> { - let (extname, path_span, tts) = match it.node { + let (extname, path_span, tts, span, attrs, ident) = it.and_then(|it| { match it.node { ItemMac(codemap::Spanned { - node: MacInvocTT(ref pth, ref tts, _), + node: MacInvocTT(pth, tts, _), .. }) => { - (pth.segments[0].identifier.name, pth.span, (*tts).clone()) + (pth.segments[0].identifier.name, pth.span, tts, it.span, it.attrs, it.ident) } _ => fld.cx.span_bug(it.span, "invalid item macro invocation") - }; + }}); let fm = fresh_mark(); let items = { @@ -706,48 +706,48 @@ pub fn expand_item_mac(it: P, } Some(rc) => match *rc { - NormalTT(ref expander, span, allow_internal_unstable) => { - if it.ident.name != parse::token::special_idents::invalid.name { + NormalTT(ref expander, tt_span, allow_internal_unstable) => { + if ident.name != parse::token::special_idents::invalid.name { fld.cx .span_err(path_span, &format!("macro {}! expects no ident argument, given '{}'", extname, - it.ident)); + ident)); return SmallVector::zero(); } fld.cx.bt_push(ExpnInfo { - call_site: it.span, + call_site: span, callee: NameAndSpan { format: MacroBang(extname), - span: span, + span: tt_span, allow_internal_unstable: allow_internal_unstable, } }); // mark before expansion: let marked_before = mark_tts(&tts[..], fm); - expander.expand(fld.cx, it.span, &marked_before[..]) + expander.expand(fld.cx, span, &marked_before[..]) } - IdentTT(ref expander, span, allow_internal_unstable) => { - if it.ident.name == parse::token::special_idents::invalid.name { + IdentTT(ref expander, tt_span, allow_internal_unstable) => { + if ident.name == parse::token::special_idents::invalid.name { fld.cx.span_err(path_span, &format!("macro {}! expects an ident argument", extname)); return SmallVector::zero(); } fld.cx.bt_push(ExpnInfo { - call_site: it.span, + call_site: span, callee: NameAndSpan { format: MacroBang(extname), - span: span, + span: tt_span, allow_internal_unstable: allow_internal_unstable, } }); // mark before expansion: let marked_tts = mark_tts(&tts[..], fm); - expander.expand(fld.cx, it.span, it.ident, marked_tts) + expander.expand(fld.cx, span, ident, marked_tts) } MacroRulesTT => { - if it.ident.name == parse::token::special_idents::invalid.name { + if ident.name == parse::token::special_idents::invalid.name { fld.cx.span_err(path_span, &format!("macro_rules! expects an ident argument") ); @@ -755,7 +755,7 @@ pub fn expand_item_mac(it: P, } fld.cx.bt_push(ExpnInfo { - call_site: it.span, + call_site: span, callee: NameAndSpan { format: MacroBang(extname), span: None, @@ -767,7 +767,7 @@ pub fn expand_item_mac(it: P, }); // DON'T mark before expansion. - let allow_internal_unstable = attr::contains_name(&it.attrs, + let allow_internal_unstable = attr::contains_name(&attrs, "allow_internal_unstable"); // ensure any #[allow_internal_unstable]s are @@ -777,18 +777,19 @@ pub fn expand_item_mac(it: P, feature_gate::emit_feature_err( &fld.cx.parse_sess.span_diagnostic, "allow_internal_unstable", - it.span, + span, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_ALLOW_INTERNAL_UNSTABLE) } + let export = attr::contains_name(&attrs, "macro_export"); let def = ast::MacroDef { - ident: it.ident, - attrs: it.attrs.clone(), + ident: ident, + attrs: attrs, id: ast::DUMMY_NODE_ID, - span: it.span, + span: span, imported_from: None, - export: attr::contains_name(&it.attrs, "macro_export"), + export: export, use_locally: true, allow_internal_unstable: allow_internal_unstable, body: tts, @@ -800,7 +801,7 @@ pub fn expand_item_mac(it: P, return SmallVector::zero(); } _ => { - fld.cx.span_err(it.span, + fld.cx.span_err(span, &format!("{}! is not legal in item position", extname)); return SmallVector::zero(); -- cgit 1.4.1-3-g733a5