rust/tests/target/configs
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
..
blank_lines_lower_bound Tidy up and pass tests 2018-03-02 15:07:13 +13:00
brace_style Prioritize single_line_fn and empty_item_single_line over brace_style 2019-02-01 00:22:47 +09:00
chain_width Add some basic tests for chain_width use 2021-04-21 21:27:50 -05:00
combine_control_expr Various cosmetic improvements (#3403) 2019-02-19 11:56:42 +09:00
comment_width Tidy up and pass tests 2018-03-02 15:07:13 +13:00
condense_wildcard_suffixes Tidy up and pass tests 2018-03-02 15:07:13 +13:00
control_brace_style Tidy up and pass tests 2018-03-02 15:07:13 +13:00
disable_all_formatting Tidy up and pass tests 2018-03-02 15:07:13 +13:00
empty_item_single_line Implement closing-block procedure without relying on missed_span module (#3691) 2019-07-17 23:07:12 +09:00
enum_discrim_align_threshold Change enum align semantics to care about absolute length, rather than difference. 2018-09-26 18:47:17 +00:00
error_on_line_overflow Tidy up and pass tests 2018-03-02 15:07:13 +13:00
error_on_unformatted Tidy up and pass tests 2018-03-02 15:07:13 +13:00
fn_args_layout stabilise fn_args_density (#3581) 2019-06-03 22:26:48 +09:00
fn_single_line Tidy up and pass tests 2018-03-02 15:07:13 +13:00
force_explicit_abi Tidy up and pass tests 2018-03-02 15:07:13 +13:00
force_multiline_block Tidy up and pass tests 2018-03-02 15:07:13 +13:00
format_generated_files Support @generated marker to skip code formatting 2021-09-14 21:22:26 -05:00
format_macro_bodies Add some tests I forgot about earlier 2018-08-01 10:41:16 +12:00
format_macro_matchers Add some tests I forgot about earlier 2018-08-01 10:41:16 +12:00
format_strings Tidy up and pass tests 2018-03-02 15:07:13 +13:00
group_imports Rename merge_imports to imports_granularity and add a Module option. 2021-01-17 11:48:47 -06:00
hard_tabs Tidy up and pass tests 2018-03-02 15:07:13 +13:00
imports_indent Tidy up and pass tests 2018-03-02 15:07:13 +13:00
imports_layout Rename merge_imports to imports_granularity and add a Module option. 2021-01-17 11:48:47 -06:00
indent_style fix "internal error: left behind trailing whitespace" with long lines 2019-02-01 19:58:38 +09:00
match_arm_blocks Don't flatten a block containing a single macro call 2020-11-05 20:45:11 -06:00
match_arm_leading_pipes fix: correct arm leading pipe check (#4880) 2021-07-25 22:53:32 -05:00
match_block_trailing_comma Tidy up and pass tests 2018-03-02 15:07:13 +13:00
merge_derives Tidy up and pass tests 2018-03-02 15:07:13 +13:00
normalize_comments Tidy up and pass tests 2018-03-02 15:07:13 +13:00
normalize_doc_attributes tests: add normalize_doc_attributes config tests (#3630) 2019-06-16 23:46:25 +09:00
remove_nested_parens add config test 2018-05-06 09:23:45 +08:00
reorder_impl_items Add reorder_impl_items config option 2018-04-05 12:49:16 +09:00
reorder_imports Tidy up and pass tests 2018-03-02 15:07:13 +13:00
reorder_modules Tidy up and pass tests 2018-03-02 15:07:13 +13:00
skip_children Add a test for #3493 2019-06-08 14:52:49 +09:00
space_before_colon Tidy up and pass tests 2018-03-02 15:07:13 +13:00
spaces_around_ranges backport new syntax to rustfmt 1.x (#4105) 2020-03-31 15:28:01 +09:00
struct_field_align_threshold handle field attributes when aligning a struct's fields (#3513) 2019-10-19 16:56:32 +09:00
struct_lit_single_line Tidy up and pass tests 2018-03-02 15:07:13 +13:00
tab_spaces Tidy up and pass tests 2018-03-02 15:07:13 +13:00
trailing_comma Tidy up and pass tests 2018-03-02 15:07:13 +13:00
trailing_semicolon Tidy up and pass tests 2018-03-02 15:07:13 +13:00
type_punctuation_density Tidy up and pass tests 2018-03-02 15:07:13 +13:00
use_field_init_shorthand Update uses of rustfmt_skip to rustfmt::skip 2018-05-14 16:25:10 +12:00
use_small_heuristics tests: augment heuristics tests 2021-04-21 21:27:50 -05:00
use_try_shorthand Tidy up and pass tests 2018-03-02 15:07:13 +13:00
where_single_line fix: don't force a newline after an empty where clause 2020-11-25 21:32:46 -06:00
wrap_comments Tidy up and pass tests 2018-03-02 15:07:13 +13:00