kevinmehall / rust-peg

Parsing Expression Grammar (PEG) parser generator for Rust
https://crates.io/crates/peg
MIT License
1.46k stars 106 forks source link

rustc warning about unused imports #352

Closed mcandre closed 1 year ago

mcandre commented 1 year ago

Hi,

I am able to use a regex initialized in lazy_static, in my grammar for some tricky {? ... } logic.

However, rustc warns that the regex is "unused". Even though it is used by the peg grammar.

I tried moving the extern crate regex; and use regex::Regex; lines into the grammar. That causes compilation to completely fail.

I tried moving the imports into lazy_static. Same behavior: Compilation fails.

Alternatively, I could construct the regex in the grammar rule every time, but that dampens performance.

How can we get rustc to witness a grammar using a lazy_static member?

kevinmehall commented 1 year ago

Please provide a complete example and the compiler error.