-
Notifications
You must be signed in to change notification settings - Fork 965
Description
rustfmt 1.x ran in "recursive" mode by default wherein all the mods within the AST would be visited and formatted, including those mods defined in external files not explicitly passed as args to rustfmt.
rustfmt 2.x inverts that behavior and will now only format files explicitly passed to rustfmt unless the --recursive flag is passed (in which case rustfmt 2.x formats everything like rustfmt 1.x)
As such a few of our test cases needed to be updated to explicitly include the recursive. Currently these tests are running in "non-recursive" mode and unintentionally ignoring some files which has resulted in a few false positves.
This can be addressed by adding the below snippet to the top of the corresponding pairs of test files under rustfmt-core/rustfmt-lib/tests/{source, target}/**
// rustfmt-recursive: trueSome (perhaps all) of the tests that need this change can be found by reviewing the skipped files in rustfmt-core/rustfmt-lib/src/test/mod.rs to determine the corresponding entry point files that need recursive enabled.
rustfmt/rustfmt-core/rustfmt-lib/src/test/mod.rs
Lines 23 to 43 in a0eb97b
| const SKIP_FILE_WHITE_LIST: &[&str] = &[ | |
| "issue-3434/no_entry.rs", | |
| "issue-3665/sub_mod.rs", | |
| // Testing for issue-3779 | |
| "issue-3779/ice.rs", | |
| // These files and directory are a part of modules defined inside `cfg_if!`. | |
| "cfg_if/mod.rs", | |
| "cfg_if/detect", | |
| "issue-3253/foo.rs", | |
| "issue-3253/bar.rs", | |
| "issue-3253/paths", | |
| // These files and directory are a part of modules defined inside `cfg_attr(..)`. | |
| "cfg_mod/dir", | |
| "cfg_mod/bar.rs", | |
| "cfg_mod/foo.rs", | |
| "cfg_mod/wasm32.rs", | |
| // We want to ensure `recursive` is working correctly, so do not test | |
| // these files directly | |
| "configs/recursive/disabled/foo.rs", | |
| "configs/recursive/enabled/foo.rs", | |
| ]; |
For example, we can see there's some test files within the cfg_if directory (rustfmt-core/rustfmt-lib/tests/{source,target}/cfg_if/mod.rs that are being explicitly ignored to validate the target behavior, so the entry test file in this case (rustfmt-core/rustfmt-lib/tests/{source,target}/cfg_if/lib.rs) needs to have recursive mode included by adding // rustfmt-recursive: true
This would be a good first issue for anyone interested in working on rustfmt!