nom is not compatible with pub(crate) and the `unreachable-pub` lint
Prerequisites
Here are a few things you should provide to help me understand the issue:
- Rust version :
rustc -V: rustc 1.28.0-nightly (cd494c1f0 2018-06-27) - nom version : 4.0.0
- nom compilation features used: default
Test case
This is the initial code. It triggers the rustc warning about unreachable-pub items.
nom-incompat.zip
The compiler suggests to restrict its visibility, by using pub(crate). After changing the line
named!(pub par, tag!("xD"));
to
named!(pub(crate) par, tag!("xD"));
The example doesn't build anymore
error: no rules expected the token `par`
--> src/protocol/parser.rs:3:19
|
3 | named!(pub(crate) par, tag!("xD"));
| ^^^
error: aborting due to previous error
To me, this looks like an issue with the way named! parses function names. It's probably not capable of handling pub(crate). However, since you're on 1.28 nightly, I think you can instead use the 'crate' access modifier - it's equivalent.
Perhaps Geal has more insight, however.
The 'crate' access modifier doesn't work either. These two snippets produce the same error (on a current nightly rustc):
named!(pub(crate) par, tag!("xD"));
named!(crate par, tag!("xD"));
#566 was merged, this will be available in the next nom version