Skip to content

Commit cb64672

Browse files
committed
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
1 parent f60d96a commit cb64672

38 files changed

+44
-50
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ macro_rules! declare_features {
8383
}
8484

8585
pub fn use_extern_macros(&self) -> bool {
86-
// The `decl_macro`, `tool_attributes` and `custom_attributes`
87-
// features imply `use_extern_macros`.
86+
// A number of "advanced" macro features enable
87+
// macro modularization (`use_extern_macros`) implicitly.
8888
self.use_extern_macros || self.decl_macro ||
89-
self.tool_attributes || self.custom_attribute
89+
self.tool_attributes || self.custom_attribute ||
90+
self.macros_in_extern || self.proc_macro_path_invoc ||
91+
self.proc_macro_mod || self.proc_macro_expr ||
92+
self.proc_macro_non_items || self.proc_macro_gen ||
93+
self.stmt_expr_attributes
9094
}
9195
}
9296
};
@@ -700,7 +704,7 @@ pub fn is_builtin_attr_name(name: ast::Name) -> bool {
700704
}
701705

702706
pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
703-
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name)) ||
707+
BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.path == builtin_name) ||
704708
attr.name().as_str().starts_with("rustc_")
705709
}
706710

src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
//! Attributes producing expressions in invalid locations
1515
16-
#![feature(use_extern_macros, stmt_expr_attributes, proc_macro_expr)]
16+
#![feature(stmt_expr_attributes, proc_macro_expr)]
1717

1818
extern crate attr_stmt_expr;
1919
use attr_stmt_expr::{duplicate, no_output};

src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// aux-build:attr-stmt-expr.rs
1212
// ignore-stage1
1313

14-
#![feature(use_extern_macros, proc_macro_expr)]
14+
#![feature(proc_macro_expr)]
1515

1616
extern crate attr_stmt_expr;
1717
use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr};

src/test/compile-fail-fulldeps/proc-macro/issue-50493.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// aux-build:issue_50493.rs
1212
// ignore-stage1
1313

14-
#![feature(proc_macro)]
15-
1614
#[macro_use]
1715
extern crate issue_50493;
1816

src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// aux-build:bang_proc_macro2.rs
1212
// ignore-stage1
1313

14-
#![feature(use_extern_macros, proc_macro_non_items)]
14+
#![feature(proc_macro_non_items)]
1515
#![allow(unused_macros)]
1616

1717
extern crate bang_proc_macro2;

src/test/compile-fail-fulldeps/proc-macro/proc-macro-custom-attr-mutex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// aux-build:attr_proc_macro.rs
1212
// ignore-tidy-linelength
1313

14-
#![feature(use_extern_macros, custom_attribute)]
14+
#![feature(custom_attribute)]
1515
//~^ ERROR Cannot use `#![feature(use_extern_macros)]` and `#![feature(custom_attribute)] at the same time
1616

1717
extern crate attr_proc_macro;

src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// gate-test-proc_macro_mod
1717
// gate-test-proc_macro_gen
1818

19-
#![feature(use_extern_macros, stmt_expr_attributes)]
19+
#![feature(stmt_expr_attributes)]
2020

2121
extern crate proc_macro_gates as foo;
2222

src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// aux-build:proc-macro-gates.rs
1212

13-
#![feature(use_extern_macros, stmt_expr_attributes)]
13+
#![feature(stmt_expr_attributes)]
1414

1515
extern crate proc_macro_gates as foo;
1616

src/test/compile-fail/macro-with-seps-err-msg.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
// gate-test-use_extern_macros
1212

13-
#![feature(proc_macro_path_invoc)]
14-
1513
fn main() {
1614
globnar::brotz!(); //~ ERROR non-ident macro paths are experimental
17-
#[derive(foo::Bar)] struct T; //~ ERROR non-ident macro paths are experimental
18-
::foo!(); //~ ERROR non-ident macro paths are experimental
1915
}

src/test/compile-fail/unknown-tool-name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(use_extern_macros, proc_macro_path_invoc)]
11+
#![feature(proc_macro_path_invoc)]
1212

1313
#[foo::bar] //~ ERROR failed to resolve. Use of undeclared type or module `foo`
1414
fn main() {}

0 commit comments

Comments
 (0)