-
-
Notifications
You must be signed in to change notification settings - Fork 282
Description
Describe the bug
The pest::parses_to! macro produces a compiler error when used in test files. Specifically, using the macro at module scope triggers error: expected item after attributes, and adding a trailing semicolon after the macro invocation produces error: expected item, found ';'. The macro fails to compile in both forms when used in integration tests, despite being
used according to documentation examples.
To Reproduce
Steps to reproduce the behavior:
- Create a Rust test file (e.g.,
tests/no_semicolon.rs) with the following contents:
use macro_parser::MarcoParser;
use macro_parser::Rule;
use pest::parses_to;
pest::parses_to! {
parser: MarcoParser,
input: "[Bookmark: X](./f.md=1)\n",
rule: Rule::bookmark,
tokens: [
bookmark(0, 21, [
text(11, 12)
])
]
}-
Run
cargo test -q --test no_semicolon. -
Observe the error:
error: expected item after attributes
--> tests/no_semicolon.rs:10:1
- Alternatively, add a trailing semicolon to the macro invocation:
pest::parses_to! {
parser: MarcoParser,
input: "[Bookmark: X](./f.md=1)\n",
rule: Rule::bookmark,
tokens: [
bookmark(0, 21, [
text(11, 12)
])
]
};-
Run
cargo test -q --test with_semicolon. -
Observe the errors:
error: expected item, found `;`
error: expected item after attributes
Expected behavior
The pest::parses_to! macro should compile successfully at module scope and generate the expected test items. No compiler errors should occur whether a trailing semicolon is present (the macro should handle both cases gracefully or clearly document that semicolons are forbidden).
Additional context
- Rust version:
- rustc 1.89.0 (29483883e 2025-08-04)
- cargo 1.89.0 (c24e10642 2025-06-23)
- stable-x86_64-unknown-linux-gnu (default)
pestversion: [2.8.1]- Issue occurs in integration test files (
tests/*.rs). - Warnings for unused imports are present but unrelated to the compilation error.
- Removing the trailing semicolon fixes the error, indicating the macro cannot tolerate a semicolon after the invocation.