Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge proc_macro_ expansion feature gates as proc_macro_hygiene #52121

Merged
merged 1 commit into from Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 10 additions & 13 deletions src/libsyntax/ext/expand.rs
Expand Up @@ -645,18 +645,18 @@ 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,
}
}
Annotatable::TraitItem(_) => return,
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,
Expand All @@ -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 {
Expand All @@ -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"),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 9 additions & 4 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -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),
Expand Down Expand Up @@ -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! (
Expand Down
Expand Up @@ -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};
Expand Down
Expand Up @@ -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};
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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)]

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs
Expand Up @@ -11,7 +11,7 @@
// no-prefer-dynamic

#![crate_type = "proc-macro"]
#![feature(proc_macro_non_items)]
#![feature(proc_macro_hygiene)]

extern crate proc_macro;

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/auxiliary/hello_macro.rs
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs
Expand Up @@ -11,7 +11,7 @@
// no-prefer-dynamic

#![crate_type = "proc-macro"]
#![feature(proc_macro_non_items)]
#![feature(proc_macro_hygiene)]

extern crate proc_macro;

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/macro-quote-cond.rs
Expand Up @@ -12,7 +12,7 @@
// aux-build:cond_plugin.rs
// ignore-stage1

#![feature(proc_macro_non_items)]
#![feature(proc_macro_hygiene)]

extern crate cond_plugin;

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/macro-quote-test.rs
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs
Expand Up @@ -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,
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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!`
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/proc-macro/bang-macro.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/proc-macro/call-site.rs
Expand Up @@ -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::*;
Expand Down
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/proc-macro/negative-token.rs
Expand Up @@ -11,7 +11,7 @@
// aux-build:negative-token.rs
// ignore-stage1

#![feature(proc_macro_non_items)]
#![feature(proc_macro_hygiene)]

extern crate negative_token;

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/proc_macro.rs
Expand Up @@ -12,7 +12,7 @@
// ignore-stage1
// ignore-cross-compile

#![feature(proc_macro_non_items)]
#![feature(proc_macro_hygiene)]

extern crate proc_macro_def;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lifetimes.rs
Expand Up @@ -10,7 +10,7 @@

// aux-build:lifetimes.rs

#![feature(proc_macro_non_items)]
#![feature(proc_macro_hygiene)]

extern crate lifetimes;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/proc-macro/macro-use-bang.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/proc-macro/multispan.rs
Expand Up @@ -11,7 +11,7 @@
// aux-build:multispan.rs
// ignore-stage1

#![feature(proc_macro_non_items)]
#![feature(proc_macro_hygiene)]

extern crate multispan;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/proc-macro/parent-source-spans.rs
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/proc-macro/three-equals.rs
Expand Up @@ -11,7 +11,7 @@
// aux-build:three-equals.rs
// ignore-stage1

#![feature(proc_macro_non_items)]
#![feature(proc_macro_hygiene)]

extern crate three_equals;

Expand Down