Auto merge of #52121 - jebrosen:macros2_feature, r=petrochenkov
Merge `proc_macro_` expansion feature gates as `proc_macro_hygiene` Merges `proc_macro_mod`, `proc_macro_expr`, `proc_macro_non_items`, and `proc_macro_gen` into a single feature: `proc_macro_hygiene`. These features are not all blocked on implementing macro hygiene *per se*, but rather on interactions with hygiene that have not been entirely resolved.
This commit is contained in:
commit
766e21c7d7
@ -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<AstFragment>) {
|
||||
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 {
|
||||
|
@ -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! (
|
||||
|
@ -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};
|
||||
|
@ -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};
|
||||
|
@ -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;
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "proc-macro"]
|
||||
#![feature(proc_macro_non_items)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "proc-macro"]
|
||||
#![feature(proc_macro_non_items)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
// aux-build:cond_plugin.rs
|
||||
// ignore-stage1
|
||||
|
||||
#![feature(proc_macro_non_items)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate cond_plugin;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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!`
|
||||
|
@ -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;
|
||||
|
@ -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::*;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -11,7 +11,7 @@
|
||||
// aux-build:negative-token.rs
|
||||
// ignore-stage1
|
||||
|
||||
#![feature(proc_macro_non_items)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate negative_token;
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
// ignore-stage1
|
||||
// ignore-cross-compile
|
||||
|
||||
#![feature(proc_macro_non_items)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate proc_macro_def;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// aux-build:lifetimes.rs
|
||||
|
||||
#![feature(proc_macro_non_items)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate lifetimes;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -11,7 +11,7 @@
|
||||
// aux-build:multispan.rs
|
||||
// ignore-stage1
|
||||
|
||||
#![feature(proc_macro_non_items)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate multispan;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
// aux-build:three-equals.rs
|
||||
// ignore-stage1
|
||||
|
||||
#![feature(proc_macro_non_items)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate three_equals;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user