From d3c902f3113575b134641c14a9734b5075d06b09 Mon Sep 17 00:00:00 2001 From: jeb Date: Thu, 5 Jul 2018 19:09:35 -0600 Subject: [PATCH] Merge the `proc_macro_` expansion feature gates into a single `proc_macro_hygiene` gate. --- src/libsyntax/ext/expand.rs | 23 ++++++++----------- src/libsyntax/feature_gate.rs | 13 +++++++---- .../proc-macro/attr-invalid-exprs.rs | 2 +- .../proc-macro/attr-stmt-expr.rs | 2 +- .../proc-macro/lints_in_proc_macros.rs | 2 +- .../proc-macro/proc-macro-gates.rs | 6 +---- .../auxiliary/cond_plugin.rs | 2 +- .../auxiliary/hello_macro.rs | 2 +- .../auxiliary/proc_macro_def.rs | 2 +- .../run-pass-fulldeps/macro-quote-cond.rs | 2 +- .../run-pass-fulldeps/macro-quote-test.rs | 2 +- .../proc-macro/attr-stmt-expr.rs | 2 +- .../auxiliary/count_compound_ops.rs | 2 +- .../auxiliary/hygiene_example_codegen.rs | 2 +- .../proc-macro/bang-macro.rs | 2 +- .../run-pass-fulldeps/proc-macro/call-site.rs | 2 +- .../proc-macro/count_compound_ops.rs | 2 +- .../proc-macro/hygiene_example.rs | 2 +- .../proc-macro/negative-token.rs | 2 +- src/test/run-pass-fulldeps/proc_macro.rs | 2 +- src/test/ui-fulldeps/lifetimes.rs | 2 +- .../ui-fulldeps/proc-macro/macro-use-bang.rs | 2 +- src/test/ui-fulldeps/proc-macro/multispan.rs | 2 +- .../proc-macro/parent-source-spans.rs | 2 +- .../ui-fulldeps/proc-macro/three-equals.rs | 2 +- 25 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 52322e98d46f9..aef1113eef96c 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -645,8 +645,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let (kind, gate) = match *item { Annotatable::Item(ref item) => { match item.node { - ItemKind::Mod(_) if self.cx.ecfg.proc_macro_mod() => return, - ItemKind::Mod(_) => ("modules", "proc_macro_mod"), + ItemKind::Mod(_) if self.cx.ecfg.proc_macro_hygiene() => return, + ItemKind::Mod(_) => ("modules", "proc_macro_hygiene"), _ => return, } } @@ -654,9 +654,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Annotatable::ImplItem(_) => return, Annotatable::ForeignItem(_) => return, Annotatable::Stmt(_) | - Annotatable::Expr(_) if self.cx.ecfg.proc_macro_expr() => return, - Annotatable::Stmt(_) => ("statements", "proc_macro_expr"), - Annotatable::Expr(_) => ("expressions", "proc_macro_expr"), + Annotatable::Expr(_) if self.cx.ecfg.proc_macro_hygiene() => return, + Annotatable::Stmt(_) => ("statements", "proc_macro_hygiene"), + Annotatable::Expr(_) => ("expressions", "proc_macro_hygiene"), }; emit_feature_err( self.cx.parse_sess, @@ -668,7 +668,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } fn gate_proc_macro_expansion(&self, span: Span, fragment: &Option) { - if self.cx.ecfg.proc_macro_gen() { + if self.cx.ecfg.proc_macro_hygiene() { return } let fragment = match fragment { @@ -691,7 +691,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { if let ast::ItemKind::MacroDef(_) = i.node { emit_feature_err( self.parse_sess, - "proc_macro_gen", + "proc_macro_hygiene", self.span, GateIssue::Language, &format!("procedural macros cannot expand to macro definitions"), @@ -885,12 +885,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> { AstFragmentKind::ImplItems => return, AstFragmentKind::ForeignItems => return, }; - if self.cx.ecfg.proc_macro_non_items() { + if self.cx.ecfg.proc_macro_hygiene() { return } emit_feature_err( self.cx.parse_sess, - "proc_macro_non_items", + "proc_macro_hygiene", span, GateIssue::Language, &format!("procedural macros cannot be expanded to {}", kind), @@ -1612,10 +1612,7 @@ impl<'feat> ExpansionConfig<'feat> { fn enable_custom_derive = custom_derive, fn enable_format_args_nl = format_args_nl, fn macros_in_extern_enabled = macros_in_extern, - fn proc_macro_mod = proc_macro_mod, - fn proc_macro_gen = proc_macro_gen, - fn proc_macro_expr = proc_macro_expr, - fn proc_macro_non_items = proc_macro_non_items, + fn proc_macro_hygiene = proc_macro_hygiene, } fn enable_custom_inner_attributes(&self) -> bool { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index adbe2f9d4393f..674740a52e679 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -441,10 +441,7 @@ declare_features! ( // Allows macro invocations on modules expressions and statements and // procedural macros to expand to non-items. - (active, proc_macro_mod, "1.27.0", Some(54727), None), - (active, proc_macro_expr, "1.27.0", Some(54727), None), - (active, proc_macro_non_items, "1.27.0", Some(54727), None), - (active, proc_macro_gen, "1.27.0", Some(54727), None), + (active, proc_macro_hygiene, "1.30.0", Some(54727), None), // #[doc(alias = "...")] (active, doc_alias, "1.27.0", Some(50146), None), @@ -541,6 +538,14 @@ declare_features! ( Some("merged into `#![feature(slice_patterns)]`")), (removed, macro_reexport, "1.0.0", Some(29638), None, Some("subsumed by `pub use`")), + (removed, proc_macro_mod, "1.27.0", Some(54727), None, + Some("subsumed by `#![feature(proc_macro_hygiene)]`")), + (removed, proc_macro_expr, "1.27.0", Some(54727), None, + Some("subsumed by `#![feature(proc_macro_hygiene)]`")), + (removed, proc_macro_non_items, "1.27.0", Some(54727), None, + Some("subsumed by `#![feature(proc_macro_hygiene)]`")), + (removed, proc_macro_gen, "1.27.0", Some(54727), None, + Some("subsumed by `#![feature(proc_macro_hygiene)]`")), ); declare_features! ( diff --git a/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs b/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs index 91b72510e3e54..f52c251c14d7b 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs @@ -13,7 +13,7 @@ //! Attributes producing expressions in invalid locations -#![feature(stmt_expr_attributes, proc_macro_expr)] +#![feature(stmt_expr_attributes, proc_macro_hygiene)] extern crate attr_stmt_expr; use attr_stmt_expr::{duplicate, no_output}; diff --git a/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs b/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs index 52b2a473ecd75..1344156b3053c 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs @@ -11,7 +11,7 @@ // aux-build:attr-stmt-expr.rs // ignore-stage1 -#![feature(proc_macro_expr)] +#![feature(proc_macro_hygiene)] extern crate attr_stmt_expr; use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr}; diff --git a/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs b/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs index 6e9d231ea99a4..60e533d3ea8d2 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs @@ -11,7 +11,7 @@ // aux-build:bang_proc_macro2.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] #![allow(unused_macros)] extern crate bang_proc_macro2; diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs index c07e6e31d6287..5049a474dd215 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs @@ -9,11 +9,7 @@ // except according to those terms. // aux-build:proc-macro-gates.rs -// gate-test-proc_macro_non_items -// gate-test-proc_macro_mod line -// gate-test-proc_macro_expr -// gate-test-proc_macro_mod -// gate-test-proc_macro_gen +// gate-test-proc_macro_hygiene #![feature(stmt_expr_attributes)] diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs index 94c5b208a3707..e7545f954daab 100644 --- a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs @@ -11,7 +11,7 @@ // no-prefer-dynamic #![crate_type = "proc-macro"] -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate proc_macro; diff --git a/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs b/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs index b54543c73fbd2..caf56dabf796a 100644 --- a/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs +++ b/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs @@ -11,7 +11,7 @@ // no-prefer-dynamic #![crate_type = "proc-macro"] -#![feature(proc_macro_non_items, proc_macro_quote)] +#![feature(proc_macro_hygiene, proc_macro_quote)] extern crate proc_macro; diff --git a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs b/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs index b9c565a9d3c23..847db0098fffc 100644 --- a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs +++ b/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs @@ -11,7 +11,7 @@ // no-prefer-dynamic #![crate_type = "proc-macro"] -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate proc_macro; diff --git a/src/test/run-pass-fulldeps/macro-quote-cond.rs b/src/test/run-pass-fulldeps/macro-quote-cond.rs index 4c36f097ec114..d438adda151fa 100644 --- a/src/test/run-pass-fulldeps/macro-quote-cond.rs +++ b/src/test/run-pass-fulldeps/macro-quote-cond.rs @@ -12,7 +12,7 @@ // aux-build:cond_plugin.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate cond_plugin; diff --git a/src/test/run-pass-fulldeps/macro-quote-test.rs b/src/test/run-pass-fulldeps/macro-quote-test.rs index 1005a6bfc50c7..f967ef56bb8f0 100644 --- a/src/test/run-pass-fulldeps/macro-quote-test.rs +++ b/src/test/run-pass-fulldeps/macro-quote-test.rs @@ -13,7 +13,7 @@ // aux-build:hello_macro.rs // ignore-stage1 -#![feature(proc_macro_non_items, proc_macro_gen)] +#![feature(proc_macro_hygiene)] extern crate hello_macro; diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs b/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs index b5272e6608bbf..8a3452f24d247 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs +++ b/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs @@ -11,7 +11,7 @@ // aux-build:attr-stmt-expr.rs // ignore-stage1 -#![feature(stmt_expr_attributes, proc_macro_expr)] +#![feature(stmt_expr_attributes, proc_macro_hygiene)] extern crate attr_stmt_expr; use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr, diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs index a84e029f9d87d..77d0d9339feff 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(proc_macro_non_items, proc_macro_quote)] +#![feature(proc_macro_hygiene, proc_macro_quote)] #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs index 43c1d5fcc8d49..551ac3863e1ab 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(proc_macro_quote, proc_macro_non_items)] +#![feature(proc_macro_quote, proc_macro_hygiene)] #![crate_type = "proc-macro"] extern crate proc_macro as proc_macro_renamed; // This does not break `quote!` diff --git a/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs b/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs index 955b6ab986d07..10fe015555557 100644 --- a/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs +++ b/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs @@ -11,7 +11,7 @@ // aux-build:bang-macro.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate bang_macro; use bang_macro::rewrite; diff --git a/src/test/run-pass-fulldeps/proc-macro/call-site.rs b/src/test/run-pass-fulldeps/proc-macro/call-site.rs index 9d2120e6764f7..b27c806f04717 100644 --- a/src/test/run-pass-fulldeps/proc-macro/call-site.rs +++ b/src/test/run-pass-fulldeps/proc-macro/call-site.rs @@ -13,7 +13,7 @@ // aux-build:call-site.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate call_site; use call_site::*; diff --git a/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs b/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs index 6601d66e586a3..07ad4f288d894 100644 --- a/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs +++ b/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs @@ -11,7 +11,7 @@ // aux-build:count_compound_ops.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate count_compound_ops; use count_compound_ops::count_compound_ops; diff --git a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs b/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs index 2d15b4e60b426..cf18bb247c769 100644 --- a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs +++ b/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs @@ -13,7 +13,7 @@ // aux-build:hygiene_example.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate hygiene_example; use hygiene_example::hello; diff --git a/src/test/run-pass-fulldeps/proc-macro/negative-token.rs b/src/test/run-pass-fulldeps/proc-macro/negative-token.rs index a793d069d1448..ccd729badebb9 100644 --- a/src/test/run-pass-fulldeps/proc-macro/negative-token.rs +++ b/src/test/run-pass-fulldeps/proc-macro/negative-token.rs @@ -11,7 +11,7 @@ // aux-build:negative-token.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate negative_token; diff --git a/src/test/run-pass-fulldeps/proc_macro.rs b/src/test/run-pass-fulldeps/proc_macro.rs index c9d7b0423ec59..27e0c23561f57 100644 --- a/src/test/run-pass-fulldeps/proc_macro.rs +++ b/src/test/run-pass-fulldeps/proc_macro.rs @@ -12,7 +12,7 @@ // ignore-stage1 // ignore-cross-compile -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate proc_macro_def; diff --git a/src/test/ui-fulldeps/lifetimes.rs b/src/test/ui-fulldeps/lifetimes.rs index 6879848d269b0..ff6464a7a3a70 100644 --- a/src/test/ui-fulldeps/lifetimes.rs +++ b/src/test/ui-fulldeps/lifetimes.rs @@ -10,7 +10,7 @@ // aux-build:lifetimes.rs -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate lifetimes; diff --git a/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs b/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs index 9a54696d1f076..d7713f48e703b 100644 --- a/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs +++ b/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs @@ -11,7 +11,7 @@ // compile-pass // aux-build:bang_proc_macro.rs -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] #[macro_use] extern crate bang_proc_macro; diff --git a/src/test/ui-fulldeps/proc-macro/multispan.rs b/src/test/ui-fulldeps/proc-macro/multispan.rs index 940ec016a5a3f..63a95ce211d7a 100644 --- a/src/test/ui-fulldeps/proc-macro/multispan.rs +++ b/src/test/ui-fulldeps/proc-macro/multispan.rs @@ -11,7 +11,7 @@ // aux-build:multispan.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate multispan; diff --git a/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs b/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs index 18f5b0f506cc2..7c30a8e328aa5 100644 --- a/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs +++ b/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs @@ -11,7 +11,7 @@ // aux-build:parent-source-spans.rs // ignore-stage1 -#![feature(decl_macro, proc_macro_non_items)] +#![feature(decl_macro, proc_macro_hygiene)] extern crate parent_source_spans; diff --git a/src/test/ui-fulldeps/proc-macro/three-equals.rs b/src/test/ui-fulldeps/proc-macro/three-equals.rs index f6b0e90da0014..dd81b1017ebc3 100644 --- a/src/test/ui-fulldeps/proc-macro/three-equals.rs +++ b/src/test/ui-fulldeps/proc-macro/three-equals.rs @@ -11,7 +11,7 @@ // aux-build:three-equals.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate three_equals;