d4ffd1efa4
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. |
||
---|---|---|
.. | ||
blank_lines_lower_bound | ||
brace_style | ||
chain_width | ||
combine_control_expr | ||
comment_width | ||
condense_wildcard_suffixes | ||
control_brace_style | ||
disable_all_formatting | ||
empty_item_single_line | ||
enum_discrim_align_threshold | ||
error_on_line_overflow | ||
error_on_unformatted | ||
fn_args_layout | ||
fn_single_line | ||
force_explicit_abi | ||
force_multiline_block | ||
format_generated_files | ||
format_macro_bodies | ||
format_macro_matchers | ||
format_strings | ||
group_imports | ||
hard_tabs | ||
imports_indent | ||
imports_layout | ||
indent_style | ||
match_arm_blocks | ||
match_arm_leading_pipes | ||
match_block_trailing_comma | ||
merge_derives | ||
normalize_comments | ||
normalize_doc_attributes | ||
remove_nested_parens | ||
reorder_impl_items | ||
reorder_imports | ||
reorder_modules | ||
skip_children | ||
space_before_colon | ||
spaces_around_ranges | ||
struct_field_align_threshold | ||
struct_lit_single_line | ||
tab_spaces | ||
trailing_comma | ||
trailing_semicolon | ||
type_punctuation_density | ||
use_field_init_shorthand | ||
use_small_heuristics | ||
use_try_shorthand | ||
where_single_line | ||
wrap_comments |