Enable macro modularization implicitly if one of "advanced" macro features is enabled

Do not mark all builtin attributes as used when macro modularization is enabled
This commit is contained in:
Vadim Petrochenkov 2018-08-04 03:37:14 +03:00
parent f60d96a477
commit cb64672e0c
38 changed files with 44 additions and 50 deletions

View File

@ -83,10 +83,14 @@ macro_rules! declare_features {
}
pub fn use_extern_macros(&self) -> bool {
// The `decl_macro`, `tool_attributes` and `custom_attributes`
// features imply `use_extern_macros`.
// A number of "advanced" macro features enable
// macro modularization (`use_extern_macros`) implicitly.
self.use_extern_macros || self.decl_macro ||
self.tool_attributes || self.custom_attribute
self.tool_attributes || self.custom_attribute ||
self.macros_in_extern || self.proc_macro_path_invoc ||
self.proc_macro_mod || self.proc_macro_expr ||
self.proc_macro_non_items || self.proc_macro_gen ||
self.stmt_expr_attributes
}
}
};
@ -700,7 +704,7 @@ pub fn is_builtin_attr_name(name: ast::Name) -> bool {
}
pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name)) ||
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.path == builtin_name) ||
attr.name().as_str().starts_with("rustc_")
}

View File

@ -13,7 +13,7 @@
//! Attributes producing expressions in invalid locations
#![feature(use_extern_macros, stmt_expr_attributes, proc_macro_expr)]
#![feature(stmt_expr_attributes, proc_macro_expr)]
extern crate attr_stmt_expr;
use attr_stmt_expr::{duplicate, no_output};

View File

@ -11,7 +11,7 @@
// aux-build:attr-stmt-expr.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_expr)]
#![feature(proc_macro_expr)]
extern crate attr_stmt_expr;
use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr};

View File

@ -11,8 +11,6 @@
// aux-build:issue_50493.rs
// ignore-stage1
#![feature(proc_macro)]
#[macro_use]
extern crate issue_50493;

View File

@ -11,7 +11,7 @@
// aux-build:bang_proc_macro2.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
#![allow(unused_macros)]
extern crate bang_proc_macro2;

View File

@ -11,7 +11,7 @@
// aux-build:attr_proc_macro.rs
// ignore-tidy-linelength
#![feature(use_extern_macros, custom_attribute)]
#![feature(custom_attribute)]
//~^ ERROR Cannot use `#![feature(use_extern_macros)]` and `#![feature(custom_attribute)] at the same time
extern crate attr_proc_macro;

View File

@ -16,7 +16,7 @@
// gate-test-proc_macro_mod
// gate-test-proc_macro_gen
#![feature(use_extern_macros, stmt_expr_attributes)]
#![feature(stmt_expr_attributes)]
extern crate proc_macro_gates as foo;

View File

@ -10,7 +10,7 @@
// aux-build:proc-macro-gates.rs
#![feature(use_extern_macros, stmt_expr_attributes)]
#![feature(stmt_expr_attributes)]
extern crate proc_macro_gates as foo;

View File

@ -10,10 +10,6 @@
// 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
::foo!(); //~ ERROR non-ident macro paths are experimental
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(use_extern_macros, proc_macro_path_invoc)]
#![feature(proc_macro_path_invoc)]
#[foo::bar] //~ ERROR failed to resolve. Use of undeclared type or module `foo`
fn main() {}

View File

@ -11,7 +11,7 @@
// no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(proc_macro, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate proc_macro;

View File

@ -11,7 +11,7 @@
// no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(use_extern_macros, proc_macro_non_items, proc_macro_quote)]
#![feature(proc_macro_non_items, proc_macro_quote)]
extern crate proc_macro;

View File

@ -11,7 +11,7 @@
// no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(proc_macro, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate proc_macro;

View File

@ -11,7 +11,7 @@
// aux-build:cond_plugin.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate cond_plugin;

View File

@ -13,7 +13,7 @@
// aux-build:hello_macro.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_non_items, proc_macro_gen)]
#![feature(proc_macro_non_items, proc_macro_gen)]
extern crate hello_macro;

View File

@ -11,7 +11,7 @@
// aux-build:attr-stmt-expr.rs
// ignore-stage1
#![feature(use_extern_macros, stmt_expr_attributes, proc_macro_expr)]
#![feature(stmt_expr_attributes, proc_macro_expr)]
extern crate attr_stmt_expr;
use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr,

View File

@ -10,7 +10,7 @@
// no-prefer-dynamic
#![feature(proc_macro_non_items, proc_macro_quote, use_extern_macros)]
#![feature(proc_macro_non_items, proc_macro_quote)]
#![crate_type = "proc-macro"]
extern crate proc_macro;

View File

@ -10,7 +10,7 @@
// no-prefer-dynamic
#![feature(use_extern_macros, proc_macro_quote, proc_macro_non_items)]
#![feature(proc_macro_quote, proc_macro_non_items)]
#![crate_type = "proc-macro"]
extern crate proc_macro as proc_macro_renamed; // This does not break `quote!`

View File

@ -11,7 +11,7 @@
// aux-build:bang-macro.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate bang_macro;
use bang_macro::rewrite;

View File

@ -11,7 +11,7 @@
// aux-build:call-site.rs
// ignore-stage1
#![feature(proc_macro_non_items, use_extern_macros)]
#![feature(proc_macro_non_items)]
extern crate call_site;
use call_site::*;

View File

@ -11,7 +11,7 @@
// aux-build:count_compound_ops.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate count_compound_ops;
use count_compound_ops::count_compound_ops;

View File

@ -11,7 +11,7 @@
// aux-build:derive-b.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_path_invoc)]
#![feature(proc_macro_path_invoc)]
extern crate derive_b;

View File

@ -12,7 +12,7 @@
// aux-build:hygiene_example.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate hygiene_example;
use hygiene_example::hello;

View File

@ -12,7 +12,7 @@
// ignore-stage1
// ignore-wasm32
#![feature(use_extern_macros, macros_in_extern)]
#![feature(macros_in_extern)]
extern crate test_macros;

View File

@ -12,7 +12,7 @@
// ignore-stage1
// ignore-cross-compile
#![feature(use_extern_macros, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate proc_macro_def;

View File

@ -10,7 +10,7 @@
// force-host
// no-prefer-dynamic
#![feature(proc_macro)]
#![crate_type = "proc-macro"]
extern crate proc_macro;

View File

@ -10,7 +10,7 @@
// force-host
// no-prefer-dynamic
#![feature(proc_macro)]
#![crate_type = "proc-macro"]
extern crate proc_macro;

View File

@ -10,7 +10,6 @@
// no-prefer-dynamic
#![feature(proc_macro)]
#![crate_type = "proc-macro"]
extern crate proc_macro;

View File

@ -10,7 +10,7 @@
// aux-build:lifetimes.rs
#![feature(use_extern_macros, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate lifetimes;

View File

@ -11,7 +11,6 @@
// run-pass
// no-prefer-dynamic
#![feature(proc_macro)]
#![crate_type = "proc-macro"]
extern crate proc_macro;

View File

@ -12,7 +12,7 @@
// aux-build:generate-mod.rs
#![feature(use_extern_macros, proc_macro_gen, proc_macro_path_invoc)]
#![feature(proc_macro_gen, proc_macro_path_invoc)]
extern crate generate_mod;

View File

@ -11,7 +11,6 @@
// no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
extern crate proc_macro;

View File

@ -1,35 +1,35 @@
error: `#[proc_macro]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:20:1
--> $DIR/invalid-attributes.rs:19:1
|
LL | #[proc_macro = "test"] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:23:1
--> $DIR/invalid-attributes.rs:22:1
|
LL | #[proc_macro()] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^
error: `#[proc_macro]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:26:1
--> $DIR/invalid-attributes.rs:25:1
|
LL | #[proc_macro(x)] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:29:1
--> $DIR/invalid-attributes.rs:28:1
|
LL | #[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:32:1
--> $DIR/invalid-attributes.rs:31:1
|
LL | #[proc_macro_attribute()] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:35:1
--> $DIR/invalid-attributes.rs:34:1
|
LL | #[proc_macro_attribute(x)] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -10,7 +10,7 @@
// no-prefer-dynamic
#![feature(proc_macro, decl_macro)]
#![feature(decl_macro)]
#![crate_type = "proc-macro"]
extern crate proc_macro;

View File

@ -10,7 +10,6 @@
// no-prefer-dynamic
#![feature(proc_macro)]
#![crate_type = "proc-macro"]
extern crate proc_macro;

View File

@ -1,5 +1,5 @@
error: functions tagged with `#[proc_macro]` must currently reside in the root of the crate
--> $DIR/non-root.rs:21:5
--> $DIR/non-root.rs:20:5
|
LL | pub fn foo(arg: TokenStream) -> TokenStream { arg }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -11,7 +11,7 @@
// aux-build:three-equals.rs
// ignore-stage1
#![feature(use_extern_macros, proc_macro_non_items)]
#![feature(proc_macro_non_items)]
extern crate three_equals;

View File

@ -10,7 +10,7 @@
// aux-build:two_macros.rs
#![feature(item_like_imports, use_extern_macros)]
#![feature(use_extern_macros)]
extern crate two_macros; // two identity macros `m` and `n`