Skip to content

Commit 349259d

Browse files
committed
Stabilize macros in extern blocks
Add some tests for macros in extern blocks, remove duplicate tests
1 parent 22bc9e1 commit 349259d

17 files changed

+37
-336
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 12 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) => {
@@ -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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `crate`, `fn`, `pub`, `static`, or `type`, found `let`
2-
--> $DIR/issue-54441.rs:5:9
2+
--> $DIR/issue-54441.rs:3:9
33
|
44
LL | let
55
| ^^^ unexpected token

0 commit comments

Comments
 (0)