Skip to content

Commit ac3d8ce

Browse files
committed
Clarify comments about doc comments in macros.
1 parent 2b60cc0 commit ac3d8ce

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,12 @@ impl<'tt> TtParser<'tt> {
517517

518518
TokenTree::Token(t) => {
519519
// If it's a doc comment, we just ignore it and move on to the next tt in
520-
// the matcher. If the token matches, we can just advance the parser.
520+
// the matcher. This is a bug, but #95267 showed that existing programs
521+
// rely on this behaviour, and changing it would require some care and a
522+
// transition period.
523+
//
524+
// If the token matches, we can just advance the parser.
525+
//
521526
// Otherwise, this match has failed, there is nothing to do, and hopefully
522527
// another item in `cur_items` will match.
523528
if matches!(t, Token { kind: DocComment(..), .. }) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// check-pass
22

3-
// This is a valid macro. Commit 4 in #95159 broke things such that it failed
4-
// with a "missing tokens in macro arguments" error, as reported in #95267.
3+
// The doc comment here is ignored. This is a bug, but #95267 showed that
4+
// existing programs rely on this behaviour, and changing it would require some
5+
// care and a transition period.
56
macro_rules! f {
67
(
78
/// ab

0 commit comments

Comments
 (0)