Skip to content

Commit 2654252

Browse files
committed
Add a sanity check
1 parent 9db50ff commit 2654252

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler/rustc_expand/src/expand.rs

+6
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
689689
return ExpandResult::Ready(invoc.fragment_kind.dummy(invoc.span()));
690690
}
691691

692+
// Sanity check: ensure that no postfix macro slips through
693+
// and accidentially gets expanded.
694+
if let InvocationKind::Bang { mac, .. } = &invoc.kind {
695+
mac.postfix_self_arg.as_ref().expect_none("postfix macro survived until expansion");
696+
}
697+
692698
let (fragment_kind, span) = (invoc.fragment_kind, invoc.span());
693699
ExpandResult::Ready(match invoc.kind {
694700
InvocationKind::Bang { mac, .. } => match ext {

compiler/rustc_expand/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![feature(proc_macro_diagnostic)]
66
#![feature(proc_macro_internals)]
77
#![feature(proc_macro_span)]
8+
#![feature(option_expect_none)]
89
#![feature(try_blocks)]
910

1011
#[macro_use]

0 commit comments

Comments
 (0)