From 79630d4fdfc775b241cae0a209edec2687a29f0f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 20 Apr 2018 07:50:39 -0700 Subject: [PATCH] rustc: Tweak custom attribute capabilities This commit starts to lay some groundwork for the stabilization of custom attribute invocations and general procedural macros. It applies a number of changes discussed on [internals] as well as a [recent issue][issue], namely: * The path used to specify a custom attribute must be of length one and cannot be a global path. This'll help future-proof us against any ambiguities and give us more time to settle the precise syntax. In the meantime though a bare identifier can be used and imported to invoke a custom attribute macro. A new feature gate, `proc_macro_path_invoc`, was added to gate multi-segment paths and absolute paths. * The set of items which can be annotated by a custom procedural attribute has been restricted. Statements, expressions, and modules are disallowed behind two new feature gates: `proc_macro_expr` and `proc_macro_mod`. * The input to procedural macro attributes has been restricted and adjusted. Today an invocation like `#[foo(bar)]` will receive `(bar)` as the input token stream, but after this PR it will only receive `bar` (the delimiters were removed). Invocations like `#[foo]` are still allowed and will be invoked in the same way as `#[foo()]`. This is a **breaking change** for all nightly users as the syntax coming in to procedural macros will be tweaked slightly. * Procedural macros (`foo!()` style) can only be expanded to item-like items by default. A separate feature gate, `proc_macro_non_items`, is required to expand to items like expressions, statements, etc. Closes #50038 [internals]: https://internals.rust-lang.org/t/help-stabilize-a-subset-of-macros-2-0/7252 [issue]: https://github.com/rust-lang/rust/issues/50038 --- src/librustc_resolve/macros.rs | 12 +++ src/libsyntax/ext/expand.rs | 75 ++++++++++++++++++- src/libsyntax/feature_gate.rs | 9 +++ .../proc-macro/attr-invalid-exprs.rs | 2 +- .../proc-macro/attr-stmt-expr.rs | 2 +- .../proc-macro/attributes-included.rs | 2 +- .../proc-macro/auxiliary/proc-macro-gates.rs | 29 +++++++ .../proc-macro/lints_in_proc_macros.rs | 2 +- .../proc-macro/macro-use-bang.rs | 2 +- .../proc-macro/proc-macro-gates.rs | 54 +++++++++++++ .../proc-macro/proc-macro-gates2.rs | 35 +++++++++ src/test/compile-fail/extern-macro.rs | 2 +- .../compile-fail/macro-with-seps-err-msg.rs | 2 + .../compile-fail/macros-nonfatal-errors.rs | 1 + .../associated-item-privacy-inherent.rs | 1 + .../privacy/associated-item-privacy-trait.rs | 1 + .../associated-item-privacy-type-binding.rs | 1 + .../compile-fail/private-inferred-type-3.rs | 1 + .../compile-fail/private-inferred-type.rs | 1 + .../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 +- .../run-pass-fulldeps/proc-macro/attr-args.rs | 6 +- .../proc-macro/attr-on-trait.rs | 2 +- .../proc-macro/attr-stmt-expr.rs | 2 +- .../proc-macro/auxiliary/attr-args.rs | 2 +- .../auxiliary/count_compound_ops.rs | 2 +- .../auxiliary/hygiene_example_codegen.rs | 2 +- .../proc-macro/bang-macro.rs | 2 +- .../proc-macro/count_compound_ops.rs | 2 +- .../run-pass-fulldeps/proc-macro/derive-b.rs | 2 +- .../proc-macro/hygiene_example.rs | 2 +- .../proc-macro/issue-42708.rs | 2 +- .../proc-macro/negative-token.rs | 2 +- src/test/run-pass-fulldeps/proc_macro.rs | 2 +- src/test/run-pass/hygiene/issue-47311.rs | 2 +- src/test/run-pass/hygiene/issue-47312.rs | 2 +- .../run-pass/hygiene/legacy_interaction.rs | 2 +- src/test/run-pass/hygiene/lexical.rs | 2 +- .../hygiene/wrap_unhygienic_example.rs | 2 +- src/test/run-pass/hygiene/xcrate.rs | 2 +- .../run-pass/paths-in-macro-invocations.rs | 2 +- .../proc-macro/parent-source-spans.rs | 2 +- .../ui-fulldeps/proc-macro/three-equals.rs | 2 +- src/test/ui/hygiene/fields.rs | 2 +- src/test/ui/hygiene/globs.rs | 2 +- src/test/ui/hygiene/impl_items.rs | 2 +- src/test/ui/hygiene/intercrate.rs | 2 +- src/test/ui/hygiene/no_implicit_prelude.rs | 2 +- src/test/ui/hygiene/privacy.rs | 2 +- src/test/ui/hygiene/trait_items.rs | 2 +- src/test/ui/imports/macro-paths.rs | 2 +- src/test/ui/imports/shadow_builtin_macros.rs | 2 +- 55 files changed, 265 insertions(+), 45 deletions(-) create mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs create mode 100644 src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs create mode 100644 src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 0388465b485..3a859c02c16 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -397,6 +397,18 @@ fn resolve_invoc_to_def(&mut self, invoc: &mut Invocation, scope: Mark, force: b fn resolve_macro_to_def(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, force: bool) -> Result { + if path.segments.len() > 1 { + if !self.session.features_untracked().proc_macro_path_invoc { + emit_feature_err( + &self.session.parse_sess, + "proc_macro_path_invoc", + path.span, + GateIssue::Language, + "paths of length greater than one in macro invocations are \ + currently unstable", + ); + } + } let def = self.resolve_macro_to_def_inner(scope, path, kind, force); if def != Err(Determinacy::Undetermined) { // Do not report duplicated errors on every undetermined resolution. diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 678c20402d6..1434e5fddea 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -514,6 +514,7 @@ fn expand_attr_invoc(&mut self, Some(kind.expect_from_annotatables(items)) } AttrProcMacro(ref mac) => { + self.gate_proc_macro_attr_item(attr.span, &item); let item_tok = TokenTree::Token(DUMMY_SP, Token::interpolated(match item { Annotatable::Item(item) => token::NtItem(item), Annotatable::TraitItem(item) => token::NtTraitItem(item.into_inner()), @@ -522,7 +523,8 @@ fn expand_attr_invoc(&mut self, Annotatable::Stmt(stmt) => token::NtStmt(stmt.into_inner()), Annotatable::Expr(expr) => token::NtExpr(expr), })).into(); - let tok_result = mac.expand(self.cx, attr.span, attr.tokens, item_tok); + let input = self.extract_proc_macro_attr_input(attr.tokens, attr.span); + let tok_result = mac.expand(self.cx, attr.span, input, item_tok); self.parse_expansion(tok_result, kind, &attr.path, attr.span) } ProcMacroDerive(..) | BuiltinDerive(..) => { @@ -539,6 +541,49 @@ fn expand_attr_invoc(&mut self, } } + fn extract_proc_macro_attr_input(&self, tokens: TokenStream, span: Span) -> TokenStream { + let mut trees = tokens.trees(); + match trees.next() { + Some(TokenTree::Delimited(_, delim)) => { + if trees.next().is_none() { + return delim.tts.into() + } + } + Some(TokenTree::Token(..)) => {} + None => return TokenStream::empty(), + } + self.cx.span_err(span, "custom attribute invocations must be \ + of the form #[foo] or #[foo(..)], the macro name must only be \ + followed by a delimiter token"); + TokenStream::empty() + } + + fn gate_proc_macro_attr_item(&self, span: Span, item: &Annotatable) { + 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"), + _ => 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"), + }; + emit_feature_err( + self.cx.parse_sess, + gate, + span, + GateIssue::Language, + &format!("custom attributes cannot be applied to {}", kind), + ); + } + /// Expand a macro invocation. Returns the result of expansion. fn expand_bang_invoc(&mut self, invoc: Invocation, @@ -665,6 +710,7 @@ fn expand_bang_invoc(&mut self, self.cx.trace_macros_diag(); kind.dummy(span) } else { + self.gate_proc_macro_expansion_kind(span, kind); invoc.expansion_data.mark.set_expn_info(ExpnInfo { call_site: span, callee: NameAndSpan { @@ -695,6 +741,30 @@ fn expand_bang_invoc(&mut self, } } + fn gate_proc_macro_expansion_kind(&self, span: Span, kind: ExpansionKind) { + let kind = match kind { + ExpansionKind::Expr => "expressions", + ExpansionKind::OptExpr => "expressions", + ExpansionKind::Pat => "patterns", + ExpansionKind::Ty => "types", + ExpansionKind::Stmts => "statements", + ExpansionKind::Items => return, + ExpansionKind::TraitItems => return, + ExpansionKind::ImplItems => return, + ExpansionKind::ForeignItems => return, + }; + if self.cx.ecfg.proc_macro_non_items() { + return + } + emit_feature_err( + self.cx.parse_sess, + "proc_macro_non_items", + span, + GateIssue::Language, + &format!("procedural macros cannot be expanded to {}", kind), + ); + } + /// Expand a derive invocation. Returns the result of expansion. fn expand_derive_invoc(&mut self, invoc: Invocation, @@ -1370,6 +1440,9 @@ fn enable_allow_internal_unstable = allow_internal_unstable, fn enable_custom_derive = custom_derive, fn proc_macro_enabled = proc_macro, fn macros_in_extern_enabled = macros_in_extern, + fn proc_macro_mod = proc_macro_mod, + fn proc_macro_expr = proc_macro_expr, + fn proc_macro_non_items = proc_macro_non_items, } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 7b7cfe5eea0..6426c9a92f2 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -451,6 +451,15 @@ pub fn walk_feature_fields(&self, mut f: F) (active, mmx_target_feature, "1.27.0", None, None), (active, sse4a_target_feature, "1.27.0", None, None), (active, tbm_target_feature, "1.27.0", None, None), + + // Allows macro invocations of the form `#[foo::bar]` + (active, proc_macro_path_invoc, "1.27.0", None, None), + + // Allows macro invocations on modules expressions and statements and + // procedural macros to expand to non-items. + (active, proc_macro_mod, "1.27.0", None, None), + (active, proc_macro_expr, "1.27.0", None, None), + (active, proc_macro_non_items, "1.27.0", None, None), ); 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 2f65bd16bb5..749d87e37b5 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(proc_macro, stmt_expr_attributes)] +#![feature(proc_macro, stmt_expr_attributes, proc_macro_expr)] 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 d29bc00c663..ce04fdfb976 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)] +#![feature(proc_macro, proc_macro_expr)] 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/attributes-included.rs b/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs index 2adbee1d3fb..9947e8f66ce 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs @@ -11,7 +11,7 @@ // aux-build:attributes-included.rs // ignore-stage1 -#![feature(proc_macro, rustc_attrs)] +#![feature(proc_macro, rustc_attrs, proc_macro_path_invoc)] #![warn(unused)] extern crate attributes_included; diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs new file mode 100644 index 00000000000..25579f1fc83 --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// force-host + +#![crate_type = "proc-macro"] +#![feature(proc_macro)] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro] +pub fn m(a: TokenStream) -> TokenStream { + a +} + +#[proc_macro_attribute] +pub fn a(_a: TokenStream, b: TokenStream) -> TokenStream { + b +} 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 773b16b945f..c7be3167947 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)] +#![feature(proc_macro, proc_macro_non_items)] #![allow(unused_macros)] extern crate bang_proc_macro2; diff --git a/src/test/compile-fail-fulldeps/proc-macro/macro-use-bang.rs b/src/test/compile-fail-fulldeps/proc-macro/macro-use-bang.rs index 7ecc685357e..f16ca79ca93 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/macro-use-bang.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/macro-use-bang.rs @@ -10,7 +10,7 @@ // aux-build:bang_proc_macro.rs -#![feature(proc_macro)] +#![feature(proc_macro, proc_macro_non_items)] #[macro_use] extern crate bang_proc_macro; 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 new file mode 100644 index 00000000000..0dc1c2ab2da --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs @@ -0,0 +1,54 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:proc-macro-gates.rs +// gate-test-proc_macro_non_items +// gate-test-proc_macro_path_invoc +// gate-test-proc_macro_mod line +// gate-test-proc_macro_expr +// gate-test-proc_macro_mod + +#![feature(proc_macro, stmt_expr_attributes)] + +extern crate proc_macro_gates as foo; + +use foo::*; + +#[foo::a] //~ ERROR: paths of length greater than one +fn _test() {} + +#[a] //~ ERROR: custom attributes cannot be applied to modules +mod _test2 {} + +#[a = y] //~ ERROR: must only be followed by a delimiter token +fn _test3() {} + +#[a = ] //~ ERROR: must only be followed by a delimiter token +fn _test4() {} + +#[a () = ] //~ ERROR: must only be followed by a delimiter token +fn _test5() {} + +fn main() { + #[a] //~ ERROR: custom attributes cannot be applied to statements + let _x = 2; + let _x = #[a] 2; + //~^ ERROR: custom attributes cannot be applied to expressions + + let _x: m!(u32) = 3; + //~^ ERROR: procedural macros cannot be expanded to types + if let m!(Some(_x)) = Some(3) { + //~^ ERROR: procedural macros cannot be expanded to patterns + } + let _x = m!(3); + //~^ ERROR: procedural macros cannot be expanded to expressions + m!(let _x = 3;); + //~^ ERROR: procedural macros cannot be expanded to statements +} diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs new file mode 100644 index 00000000000..a1a15afecd5 --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:proc-macro-gates.rs + +#![feature(proc_macro, stmt_expr_attributes)] + +extern crate proc_macro_gates as foo; + +use foo::*; + +// NB. these errors aren't the best errors right now, but they're definitely +// intended to be errors. Somehow using a custom attribute in these positions +// should either require a feature gate or not be allowed on stable. + +fn _test6<#[a] T>() {} +//~^ ERROR: unknown to the compiler + +fn _test7() { + match 1 { + #[a] //~ ERROR: unknown to the compiler + 0 => {} + _ => {} + } +} + +fn main() { +} diff --git a/src/test/compile-fail/extern-macro.rs b/src/test/compile-fail/extern-macro.rs index 4267103ab9a..08269ce5c7e 100644 --- a/src/test/compile-fail/extern-macro.rs +++ b/src/test/compile-fail/extern-macro.rs @@ -10,7 +10,7 @@ // #41719 -#![feature(use_extern_macros)] +#![feature(use_extern_macros, proc_macro_path_invoc)] fn main() { enum Foo {} diff --git a/src/test/compile-fail/macro-with-seps-err-msg.rs b/src/test/compile-fail/macro-with-seps-err-msg.rs index 0f123997ca1..6567a100d8c 100644 --- a/src/test/compile-fail/macro-with-seps-err-msg.rs +++ b/src/test/compile-fail/macro-with-seps-err-msg.rs @@ -10,6 +10,8 @@ // gate-test-use_extern_macros +#![feature(proc_macro_path_invoc)] + fn main() { globnar::brotz!(); //~ ERROR non-ident macro paths are experimental #[derive(foo::Bar)] struct T; //~ ERROR non-ident macro paths are experimental diff --git a/src/test/compile-fail/macros-nonfatal-errors.rs b/src/test/compile-fail/macros-nonfatal-errors.rs index 7046ee12b50..40412087cef 100644 --- a/src/test/compile-fail/macros-nonfatal-errors.rs +++ b/src/test/compile-fail/macros-nonfatal-errors.rs @@ -13,6 +13,7 @@ #![feature(asm)] #![feature(trace_macros, concat_idents)] +#![feature(proc_macro_path_invoc)] #[derive(Default)] //~ ERROR enum OrDeriveThis {} diff --git a/src/test/compile-fail/privacy/associated-item-privacy-inherent.rs b/src/test/compile-fail/privacy/associated-item-privacy-inherent.rs index 63cb6e82c25..b64829edaa2 100644 --- a/src/test/compile-fail/privacy/associated-item-privacy-inherent.rs +++ b/src/test/compile-fail/privacy/associated-item-privacy-inherent.rs @@ -10,6 +10,7 @@ #![feature(decl_macro, associated_type_defaults)] #![allow(unused, private_in_public)] +#![feature(proc_macro_path_invoc)] mod priv_nominal { pub struct Pub; diff --git a/src/test/compile-fail/privacy/associated-item-privacy-trait.rs b/src/test/compile-fail/privacy/associated-item-privacy-trait.rs index bdc0c680a92..062dc533617 100644 --- a/src/test/compile-fail/privacy/associated-item-privacy-trait.rs +++ b/src/test/compile-fail/privacy/associated-item-privacy-trait.rs @@ -10,6 +10,7 @@ // ignore-tidy-linelength +#![feature(proc_macro_path_invoc)] #![feature(decl_macro, associated_type_defaults)] #![allow(unused, private_in_public)] diff --git a/src/test/compile-fail/privacy/associated-item-privacy-type-binding.rs b/src/test/compile-fail/privacy/associated-item-privacy-type-binding.rs index c25616c5435..0dfa61a18ab 100644 --- a/src/test/compile-fail/privacy/associated-item-privacy-type-binding.rs +++ b/src/test/compile-fail/privacy/associated-item-privacy-type-binding.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(proc_macro_path_invoc)] #![feature(decl_macro, associated_type_defaults)] #![allow(unused, private_in_public)] diff --git a/src/test/compile-fail/private-inferred-type-3.rs b/src/test/compile-fail/private-inferred-type-3.rs index 0c393f02323..97d6b470d33 100644 --- a/src/test/compile-fail/private-inferred-type-3.rs +++ b/src/test/compile-fail/private-inferred-type-3.rs @@ -18,6 +18,7 @@ // error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is priv // error-pattern:type `for<'r> fn(&'r ext::Pub) {>::priv_method}` is private +#![feature(proc_macro_path_invoc)] #![feature(decl_macro)] extern crate private_inferred_type as ext; diff --git a/src/test/compile-fail/private-inferred-type.rs b/src/test/compile-fail/private-inferred-type.rs index 5af8b063c16..dfc0107e075 100644 --- a/src/test/compile-fail/private-inferred-type.rs +++ b/src/test/compile-fail/private-inferred-type.rs @@ -11,6 +11,7 @@ #![feature(associated_consts)] #![feature(decl_macro)] #![allow(private_in_public)] +#![feature(proc_macro_path_invoc)] mod m { fn priv_fn() {} diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs index 281ee70815e..9e1ae59c01b 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)] +#![feature(proc_macro, proc_macro_non_items)] 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 cf6584e961a..a680698df9a 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, proc_macro_lib)] +#![feature(proc_macro, proc_macro_lib, proc_macro_non_items)] 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 d3670ae66fe..a280b3d87c6 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, proc_macro_lib)] +#![feature(proc_macro, proc_macro_lib, proc_macro_non_items)] 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 cff743bdae6..52e8e75f262 100644 --- a/src/test/run-pass-fulldeps/macro-quote-cond.rs +++ b/src/test/run-pass-fulldeps/macro-quote-cond.rs @@ -11,7 +11,7 @@ // aux-build:cond_plugin.rs // ignore-stage1 -#![feature(proc_macro)] +#![feature(proc_macro, proc_macro_non_items)] 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 eb77895e2d7..9bb8f691915 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)] +#![feature(proc_macro, proc_macro_path_invoc, proc_macro_non_items)] extern crate hello_macro; diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs b/src/test/run-pass-fulldeps/proc-macro/attr-args.rs index 2968cc7871d..bf7ac507ea5 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs +++ b/src/test/run-pass-fulldeps/proc-macro/attr-args.rs @@ -12,7 +12,7 @@ // ignore-stage1 #![allow(warnings)] -#![feature(proc_macro)] +#![feature(proc_macro, proc_macro_path_invoc)] extern crate attr_args; use attr_args::attr_with_args; @@ -20,6 +20,6 @@ #[attr_with_args(text = "Hello, world!")] fn foo() {} -#[::attr_args::identity - fn main() { assert_eq!(foo(), "Hello, world!"); }] +#[::attr_args::identity( + fn main() { assert_eq!(foo(), "Hello, world!"); })] struct Dummy; diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs b/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs index 52a8652e65b..95e4f2211c6 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs +++ b/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs @@ -11,7 +11,7 @@ // aux-build:attr-on-trait.rs // ignore-stage1 -#![feature(proc_macro)] +#![feature(proc_macro, proc_macro_path_invoc)] extern crate attr_on_trait; 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 98316c62ef1..d928f8e5573 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(proc_macro, stmt_expr_attributes)] +#![feature(proc_macro, stmt_expr_attributes, proc_macro_stmt, proc_macro_expr)] 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/attr-args.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs index 93815d16837..5f12cc96e9f 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs @@ -20,7 +20,7 @@ pub fn attr_with_args(args: TokenStream, input: TokenStream) -> TokenStream { let args = args.to_string(); - assert_eq!(args, r#"( text = "Hello, world!" )"#); + assert_eq!(args, r#"text = "Hello, world!""#); let input = input.to_string(); 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 063d8dc4053..5376d274045 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)] +#![feature(proc_macro, proc_macro_non_items)] #![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 055e4e2fad7..b8562ffc344 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)] +#![feature(proc_macro, proc_macro_non_items)] #![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 ffa4731f1e6..82337022ac3 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)] +#![feature(proc_macro, proc_macro_non_items)] extern crate bang_macro; use bang_macro::rewrite; 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 00ad0e76ed0..3fbe5366b6a 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)] +#![feature(proc_macro, proc_macro_non_items)] extern crate count_compound_ops; use count_compound_ops::count_compound_ops; diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-b.rs b/src/test/run-pass-fulldeps/proc-macro/derive-b.rs index 995dc65729a..d4176c0efbf 100644 --- a/src/test/run-pass-fulldeps/proc-macro/derive-b.rs +++ b/src/test/run-pass-fulldeps/proc-macro/derive-b.rs @@ -11,7 +11,7 @@ // aux-build:derive-b.rs // ignore-stage1 -#![feature(proc_macro)] +#![feature(proc_macro, proc_macro_path_invoc)] extern crate derive_b; 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 4cac7d19b4d..48de15b934d 100644 --- a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs +++ b/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs @@ -12,7 +12,7 @@ // aux-build:hygiene_example.rs // ignore-stage1 -#![feature(proc_macro)] +#![feature(proc_macro, proc_macro_non_items)] extern crate hygiene_example; use hygiene_example::hello; diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs b/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs index e53e94ae475..a6b7d93c279 100644 --- a/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs +++ b/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs @@ -11,7 +11,7 @@ // aux-build:issue-42708.rs // ignore-stage1 -#![feature(decl_macro, proc_macro)] +#![feature(decl_macro, proc_macro, proc_macro_path_invoc)] #![allow(unused)] extern crate issue_42708; 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 418e692fa24..1cdf1daf560 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)] +#![feature(proc_macro, proc_macro_non_items)] 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 cdda723585b..aad94c89f2a 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)] +#![feature(proc_macro, proc_macro_non_items)] extern crate proc_macro_def; diff --git a/src/test/run-pass/hygiene/issue-47311.rs b/src/test/run-pass/hygiene/issue-47311.rs index 3b6890cdce6..c4391ad0577 100644 --- a/src/test/run-pass/hygiene/issue-47311.rs +++ b/src/test/run-pass/hygiene/issue-47311.rs @@ -10,7 +10,7 @@ // ignore-pretty pretty-printing is unhygienic -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] #![allow(unused)] macro m($S:ident, $x:ident) { diff --git a/src/test/run-pass/hygiene/issue-47312.rs b/src/test/run-pass/hygiene/issue-47312.rs index 5e83f3808d8..0cda0e7c7cc 100644 --- a/src/test/run-pass/hygiene/issue-47312.rs +++ b/src/test/run-pass/hygiene/issue-47312.rs @@ -10,7 +10,7 @@ // ignore-pretty pretty-printing is unhygienic -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] #![allow(unused)] mod foo { diff --git a/src/test/run-pass/hygiene/legacy_interaction.rs b/src/test/run-pass/hygiene/legacy_interaction.rs index 683a15b99ae..5395ef35882 100644 --- a/src/test/run-pass/hygiene/legacy_interaction.rs +++ b/src/test/run-pass/hygiene/legacy_interaction.rs @@ -12,7 +12,7 @@ // aux-build:legacy_interaction.rs -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] #[allow(unused)] extern crate legacy_interaction; diff --git a/src/test/run-pass/hygiene/lexical.rs b/src/test/run-pass/hygiene/lexical.rs index cb02a17fec3..73deda0777e 100644 --- a/src/test/run-pass/hygiene/lexical.rs +++ b/src/test/run-pass/hygiene/lexical.rs @@ -10,7 +10,7 @@ // ignore-pretty pretty-printing is unhygienic -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] mod bar { mod baz { diff --git a/src/test/run-pass/hygiene/wrap_unhygienic_example.rs b/src/test/run-pass/hygiene/wrap_unhygienic_example.rs index 55206950214..66e83eb7cac 100644 --- a/src/test/run-pass/hygiene/wrap_unhygienic_example.rs +++ b/src/test/run-pass/hygiene/wrap_unhygienic_example.rs @@ -13,7 +13,7 @@ // aux-build:my_crate.rs // aux-build:unhygienic_example.rs -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] extern crate unhygienic_example; extern crate my_crate; // (b) diff --git a/src/test/run-pass/hygiene/xcrate.rs b/src/test/run-pass/hygiene/xcrate.rs index 6df3a34d3c8..95d7ae6db60 100644 --- a/src/test/run-pass/hygiene/xcrate.rs +++ b/src/test/run-pass/hygiene/xcrate.rs @@ -12,7 +12,7 @@ // aux-build:xcrate.rs -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] extern crate xcrate; diff --git a/src/test/run-pass/paths-in-macro-invocations.rs b/src/test/run-pass/paths-in-macro-invocations.rs index 69f8906778a..2e87809a84e 100644 --- a/src/test/run-pass/paths-in-macro-invocations.rs +++ b/src/test/run-pass/paths-in-macro-invocations.rs @@ -10,7 +10,7 @@ // aux-build:two_macros.rs -#![feature(use_extern_macros)] +#![feature(use_extern_macros, proc_macro_path_invoc)] extern crate two_macros; 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 4c71afbac4d..f938700e515 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(proc_macro, decl_macro)] +#![feature(proc_macro, decl_macro, proc_macro_non_items)] 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 ef2d1605290..66e34afcb13 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)] +#![feature(proc_macro, proc_macro_non_items)] extern crate three_equals; diff --git a/src/test/ui/hygiene/fields.rs b/src/test/ui/hygiene/fields.rs index 64217770b13..ed155b28037 100644 --- a/src/test/ui/hygiene/fields.rs +++ b/src/test/ui/hygiene/fields.rs @@ -10,7 +10,7 @@ // ignore-pretty pretty-printing is unhygienic -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] mod foo { struct S { x: u32 } diff --git a/src/test/ui/hygiene/globs.rs b/src/test/ui/hygiene/globs.rs index 7ba217061c6..f3f400aafeb 100644 --- a/src/test/ui/hygiene/globs.rs +++ b/src/test/ui/hygiene/globs.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] mod foo { pub fn f() {} diff --git a/src/test/ui/hygiene/impl_items.rs b/src/test/ui/hygiene/impl_items.rs index cdba559445d..4f997a790e6 100644 --- a/src/test/ui/hygiene/impl_items.rs +++ b/src/test/ui/hygiene/impl_items.rs @@ -10,7 +10,7 @@ // ignore-pretty pretty-printing is unhygienic -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] mod foo { struct S; diff --git a/src/test/ui/hygiene/intercrate.rs b/src/test/ui/hygiene/intercrate.rs index 50fc985ba34..20ca918f026 100644 --- a/src/test/ui/hygiene/intercrate.rs +++ b/src/test/ui/hygiene/intercrate.rs @@ -14,7 +14,7 @@ // error-pattern:type `fn() -> u32 {intercrate::foo::bar::f}` is private -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] extern crate intercrate; diff --git a/src/test/ui/hygiene/no_implicit_prelude.rs b/src/test/ui/hygiene/no_implicit_prelude.rs index c90c7b3093c..ea6a45fba6a 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.rs +++ b/src/test/ui/hygiene/no_implicit_prelude.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] mod foo { pub macro m() { Vec::new(); ().clone() } diff --git a/src/test/ui/hygiene/privacy.rs b/src/test/ui/hygiene/privacy.rs index 987cad187d4..8a392db92f9 100644 --- a/src/test/ui/hygiene/privacy.rs +++ b/src/test/ui/hygiene/privacy.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] mod foo { fn f() {} diff --git a/src/test/ui/hygiene/trait_items.rs b/src/test/ui/hygiene/trait_items.rs index 3bd19cbc0ac..d0da6254b9b 100644 --- a/src/test/ui/hygiene/trait_items.rs +++ b/src/test/ui/hygiene/trait_items.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(decl_macro)] +#![feature(decl_macro, proc_macro_path_invoc)] mod foo { pub trait T { diff --git a/src/test/ui/imports/macro-paths.rs b/src/test/ui/imports/macro-paths.rs index e709eeee14a..51e5257be1b 100644 --- a/src/test/ui/imports/macro-paths.rs +++ b/src/test/ui/imports/macro-paths.rs @@ -10,7 +10,7 @@ // aux-build:two_macros.rs -#![feature(use_extern_macros)] +#![feature(use_extern_macros, proc_macro_path_invoc)] extern crate two_macros; diff --git a/src/test/ui/imports/shadow_builtin_macros.rs b/src/test/ui/imports/shadow_builtin_macros.rs index 93de136c405..aad0a43be26 100644 --- a/src/test/ui/imports/shadow_builtin_macros.rs +++ b/src/test/ui/imports/shadow_builtin_macros.rs @@ -10,7 +10,7 @@ // aux-build:two_macros.rs -#![feature(use_extern_macros)] +#![feature(use_extern_macros, proc_macro_path_invoc)] mod foo { extern crate two_macros; -- GitLab