Skip to content

Commit 8bae91d

Browse files
authored
Rollup merge of rust-lang#63931 - petrochenkov:stabmac, r=Centril
Stabilize macros in some more positions - Fn-like macros and attribute macros in `extern` blocks - Fn-like procedural macros in type positions - ~Attribute macros on inline modules~ (moved to rust-lang#64273) Stabilization report: rust-lang#63931 (comment). Closes rust-lang#49476 cc rust-lang#54727
2 parents 3ca5804 + 5ae38bb commit 8bae91d

24 files changed

+60
-363
lines changed

src/librustc_macros/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(proc_macro_hygiene)]
21
#![allow(rustc::default_hash_types)]
32

43
#![recursion_limit="128"]

src/libsyntax/ext/expand.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -555,15 +555,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
555555
}
556556

557557
fn expand_invoc(&mut self, invoc: Invocation, ext: &SyntaxExtensionKind) -> AstFragment {
558-
let (fragment_kind, span) = (invoc.fragment_kind, invoc.span());
559-
if fragment_kind == AstFragmentKind::ForeignItems && !self.cx.ecfg.macros_in_extern() {
560-
if let SyntaxExtensionKind::NonMacroAttr { .. } = ext {} else {
561-
emit_feature_err(&self.cx.parse_sess, sym::macros_in_extern,
562-
span, GateIssue::Language,
563-
"macro invocations in `extern {}` blocks are experimental");
564-
}
565-
}
566-
567558
if self.cx.current_expansion.depth > self.cx.ecfg.recursion_limit {
568559
let expn_data = self.cx.current_expansion.id.expn_data();
569560
let suggested_limit = self.cx.ecfg.recursion_limit * 2;
@@ -578,6 +569,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
578569
FatalError.raise();
579570
}
580571

572+
let (fragment_kind, span) = (invoc.fragment_kind, invoc.span());
581573
match invoc.kind {
582574
InvocationKind::Bang { mac, .. } => match ext {
583575
SyntaxExtensionKind::Bang(expander) => {
@@ -758,14 +750,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
758750

759751
fn gate_proc_macro_expansion_kind(&self, span: Span, kind: AstFragmentKind) {
760752
let kind = match kind {
761-
AstFragmentKind::Expr => "expressions",
753+
AstFragmentKind::Expr |
762754
AstFragmentKind::OptExpr => "expressions",
763755
AstFragmentKind::Pat => "patterns",
764-
AstFragmentKind::Ty => "types",
765756
AstFragmentKind::Stmts => "statements",
766-
AstFragmentKind::Items => return,
767-
AstFragmentKind::TraitItems => return,
768-
AstFragmentKind::ImplItems => return,
757+
AstFragmentKind::Ty |
758+
AstFragmentKind::Items |
759+
AstFragmentKind::TraitItems |
760+
AstFragmentKind::ImplItems |
769761
AstFragmentKind::ForeignItems => return,
770762
AstFragmentKind::Arms
771763
| AstFragmentKind::Fields
@@ -1578,9 +1570,6 @@ impl<'feat> ExpansionConfig<'feat> {
15781570
}
15791571
}
15801572

1581-
fn macros_in_extern(&self) -> bool {
1582-
self.features.map_or(false, |features| features.macros_in_extern)
1583-
}
15841573
fn proc_macro_hygiene(&self) -> bool {
15851574
self.features.map_or(false, |features| features.proc_macro_hygiene)
15861575
}

src/libsyntax/feature_gate/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ declare_features! (
245245
(accepted, bind_by_move_pattern_guards, "1.39.0", Some(15287), None),
246246
/// Allows attributes in formal function parameters.
247247
(accepted, param_attrs, "1.39.0", Some(60406), None),
248+
// Allows macro invocations in `extern {}` blocks.
249+
(accepted, macros_in_extern, "1.40.0", Some(49476), None),
248250

249251
// -------------------------------------------------------------------------
250252
// feature-group-end: accepted features

src/libsyntax/feature_gate/active.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,6 @@ declare_features! (
402402
/// Allows infering `'static` outlives requirements (RFC 2093).
403403
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),
404404

405-
/// Allows macro invocations in `extern {}` blocks.
406-
(active, macros_in_extern, "1.27.0", Some(49476), None),
407-
408405
/// Allows accessing fields of unions inside `const` functions.
409406
(active, const_fn_union, "1.27.0", Some(51909), None),
410407

src/test/ui/abi/macros/macros-in-extern.stderr

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/test/ui/abi/proc-macro/auxiliary/test-macros.rs

Lines changed: 0 additions & 112 deletions
This file was deleted.

src/test/ui/abi/proc-macro/macros-in-extern.stderr

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/test/ui/feature-gates/feature-gate-macros_in_extern.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/test/ui/feature-gates/feature-gate-macros_in_extern.stderr

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/test/ui/macros/issue-54441.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(macros_in_extern)]
2-
31
macro_rules! m {
42
() => {
53
let //~ ERROR expected

0 commit comments

Comments
 (0)