about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-03-29 13:27:59 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-03-30 10:42:47 +1100
commitac3d8ce1c6c5a40dfe1203e9873ace219a6e20cf (patch)
tree013bc8c4ffef0303208f5197d3926b05c9924d2c
parent2b60cc081b31c48a5d9037ba559b6be32974a14f (diff)
downloadrust-ac3d8ce1c6c5a40dfe1203e9873ace219a6e20cf.tar.gz
rust-ac3d8ce1c6c5a40dfe1203e9873ace219a6e20cf.zip
Clarify comments about doc comments in macros.
-rw-r--r--compiler/rustc_expand/src/mbe/macro_parser.rs7
-rw-r--r--src/test/ui/macros/issue-95267.rs5
2 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs
index 9d134e398cc..c65b96d4365 100644
--- a/compiler/rustc_expand/src/mbe/macro_parser.rs
+++ b/compiler/rustc_expand/src/mbe/macro_parser.rs
@@ -517,7 +517,12 @@ impl<'tt> TtParser<'tt> {
 
                     TokenTree::Token(t) => {
                         // If it's a doc comment, we just ignore it and move on to the next tt in
-                        // the matcher. If the token matches, we can just advance the parser.
+                        // the matcher. This is a bug, but #95267 showed that existing programs
+                        // rely on this behaviour, and changing it would require some care and a
+                        // transition period.
+                        //
+                        // If the token matches, we can just advance the parser.
+                        //
                         // Otherwise, this match has failed, there is nothing to do, and hopefully
                         // another item in `cur_items` will match.
                         if matches!(t, Token { kind: DocComment(..), .. }) {
diff --git a/src/test/ui/macros/issue-95267.rs b/src/test/ui/macros/issue-95267.rs
index 4d59c7ea5e9..a2fe402bccf 100644
--- a/src/test/ui/macros/issue-95267.rs
+++ b/src/test/ui/macros/issue-95267.rs
@@ -1,7 +1,8 @@
 // check-pass
 
-// This is a valid macro. Commit 4 in #95159 broke things such that it failed
-// with a "missing tokens in macro arguments" error, as reported in #95267.
+// The doc comment here is ignored. This is a bug, but #95267 showed that
+// existing programs rely on this behaviour, and changing it would require some
+// care and a transition period.
 macro_rules! f {
     (
         /// ab