rustfmt: Module declared inside macro is not checked
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)
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 5
- Comments: 16 (10 by maintainers)
Commits related to this issue
- Rollup merge of #60995 - topecongiro:parser-from-stream-and-base-dir, r=michaelwoerister Add stream_to_parser_with_base_dir This PR adds `stream_to_parser_with_base_dir`, which creates a parser from... — committed to Centril/rust by Centril 8 years ago
- Rollup merge of #60995 - topecongiro:parser-from-stream-and-base-dir, r=michaelwoerister Add stream_to_parser_with_base_dir This PR adds `stream_to_parser_with_base_dir`, which creates a parser from... — committed to Centril/rust by Centril 8 years ago
- Rollup merge of #60995 - topecongiro:parser-from-stream-and-base-dir, r=michaelwoerister Add stream_to_parser_with_base_dir This PR adds `stream_to_parser_with_base_dir`, which creates a parser from... — committed to Centril/rust by Centril 7 years ago
- Rollup merge of #60995 - topecongiro:parser-from-stream-and-base-dir, r=michaelwoerister Add stream_to_parser_with_base_dir This PR adds `stream_to_parser_with_base_dir`, which creates a parser from... — committed to Centril/rust by Centril 7 years ago
- Format all source files cargo-fmt skips files because of https://github.com/rust-lang/rustfmt/issues/3253 — committed to Luminiscental/aoc2021 by Luminiscental 5 years ago
- Merge #1854 1854: Reformat everything r=rtzoeller a=SUPERCILEX Unfortunately, https://github.com/nix-rust/nix/pull/1748 didn't do the trick because of https://github.com/rust-lang/rustfmt/issues/325... — committed to nix-rust/nix by bors[bot] 4 years ago
- rustfmt modules included with if_feature! macro rustfmt has a known limitation (https://github.com/rust-lang/rustfmt/issues/3253) that modules declared inside macros are not processed when using 'car... — committed to wfraser/dropbox-sdk-rust by wfraser 2 years ago
- rustfmt modules included with if_feature! macro rustfmt has a known limitation (https://github.com/rust-lang/rustfmt/issues/3253) that modules declared inside macros are not processed when using 'car... — committed to wfraser/dropbox-sdk-rust by wfraser 2 years ago
- rustfmt modules included with if_feature! macro rustfmt has a known limitation (https://github.com/rust-lang/rustfmt/issues/3253) that modules declared inside macros are not processed when using 'car... — committed to dropbox/dropbox-sdk-rust by wfraser 2 years ago
- fix: Don't include modules via a macro (#935) ## What changes are proposed in this pull request? Turns out `rustfmt` won't format module files that are included via a macro. See [here](https://githu... — committed to delta-io/delta-kernel-rs by nicklan 2 years ago
Currently running into this problem as well.
While it does make sense not to parse every macro like that, what if there was a
#[rustfmt::follow_modules]attribute or something similar? It would go on macros where you want rustfmt to parse and find modules.That’d be too costly for a formatter that’s supposed to only process the lexical level of the crate. In particular, procedural macros require compilation. If the procedural macro fails to compile, that would result in an error, which breaks backward compatibility of rustfmt.