rust/tests
Seiichi Uchida d4ffd1efa4 Support @generated marker to skip code formatting
This is a copy of #4296 with these changes:
* file is not reopened again to find if the file is generated
* first five lines are scanned for `@generated` marker instead of one
* no attempt is made to only search for marker in comments

`@generated` marker is used by certain tools to understand that the
file is generated, so it should be treated differently than a file
written by a human:
* linters should not be invoked on these files,
* diffs in these files are less important,
* and these files should not be reformatted.

This PR proposes builtin support for `@generated` marker.

I have not found a standard for a generated file marker, but:
* Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated)
* Phabricator tool which was spawned from Facebook internal tool
  [also understands `@generated` marker](https://git.io/JnVHa)
* Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP)

My personal story is that rust-protobuf project which I maintain
was broken twice because of incompatibilities/bugs in rustfmt marker
handling: [one](https://github.com/stepancheg/rust-protobuf/issues/493),
[two](https://github.com/stepancheg/rust-protobuf/issues/551).
(Also, rust-protobuf started generating `@generated` marker
[6 years ago](https://git.io/JnV5h)).

While rustfmt AST markers are useful to apply to a certain AST
elements, disable whole-file-at-once all-tools-at-once text level
marker might be easier to use and more reliable for generated code.
2021-09-14 21:22:26 -05:00
..
cargo-fmt Add #[ignore] to test that runs external process (#3690) 2019-07-16 19:36:23 +09:00
config chore: backport 8157a3f0afe978d3e953420577f8344db7e905bf 2020-07-15 09:19:21 -05:00
coverage Replace WriteMode with EmitMode and backup bool 2018-05-21 14:14:09 +12:00
license-template fix: handling of empty str for license template path (#3804) 2019-09-24 09:24:05 +09:00
mod-resolver/issue-4874 fix(rustfmt): load nested out-of-line mods correctly 2021-06-17 22:35:19 -05:00
parser tests: add test for panic on new_parser_from_file 2020-11-02 18:31:51 -06:00
rustfmt Cargo fmt 2019-09-24 09:26:50 +09:00
source Support @generated marker to skip code formatting 2021-09-14 21:22:26 -05:00
target Support @generated marker to skip code formatting 2021-09-14 21:22:26 -05:00
writemode Fix line numbers in checkstyle output (#3694) 2019-08-19 11:11:35 +09:00