about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-09-03 06:10:27 +0000
committerbors <bors@rust-lang.org>2021-09-03 06:10:27 +0000
commitfbdff7fae941bce21fd3047f87777c84b866850e (patch)
tree8d62d5441c2f92be6538c8cf74f316bd396246ce /src
parent29d8fb746d3c7c0364f123e3efde90700b93aed3 (diff)
parent99407584161510e5ab3c6453700537bf6123e158 (diff)
downloadrust-fbdff7fae941bce21fd3047f87777c84b866850e.tar.gz
rust-fbdff7fae941bce21fd3047f87777c84b866850e.zip
Auto merge of #88428 - petrochenkov:stmtid, r=Aaron1011
expand: Treat more macro calls as statement macro calls

This PR implements the suggestion from https://github.com/rust-lang/rust/pull/87981#issuecomment-906641052 and treats fn-like macro calls inside `StmtKind::Item` and `StmtKind::Semi` as statement macro calls, which is consistent with treatment of attribute invocations in the same positions and with token-based macro expansion model in general.

This also allows to remove a special case in `NodeId` assignment (previously tried in #87779), and to use statement `NodeId`s for linting (`assign_id!`).

r? `@Aaron1011`
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/macros/issue-87877.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/macros/issue-87877.rs b/src/test/ui/macros/issue-87877.rs
new file mode 100644
index 00000000000..a40e2c5f970
--- /dev/null
+++ b/src/test/ui/macros/issue-87877.rs
@@ -0,0 +1,25 @@
+// check-pass
+
+macro_rules! two_items {
+    () => {
+        extern "C" {}
+        extern "C" {}
+    };
+}
+
+macro_rules! single_expr_funneler {
+    ($expr:expr) => {
+        $expr; // note the semicolon, it changes the statement kind during parsing
+    };
+}
+
+macro_rules! single_item_funneler {
+    ($item:item) => {
+        $item
+    };
+}
+
+fn main() {
+    single_expr_funneler! { two_items! {} }
+    single_item_funneler! { two_items! {} }
+}