Module declared inside macro is not checked
Open
Nobody has claimed this yet.
A-macros
A-modules
C-bug
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
When I declare modules like this
#[cfg(unix)]
pub mod stub_hal;
rustfmt will check module, irrespective of condition.
However, when I declare them using cfg-if crate rustfmt doesn't check module.
cfg_if! {
if #[cfg(unix)] {
pub mod stub_hal;
}
}
Is is designed behavior? Or is macro parsing not implemented for now?
That's rustfmt 1.0.1-nightly (be13559 2018-12-10)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the cfg_if! example from the issue with rustfmt and compare it with the direct #[cfg(unix)] module declaration. Trace how rustfmt handles the module inside the macro, then verify that the intended behavior is defined and that the stub_hal module is checked consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100