summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/configs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/tools/rustfmt/tests/target/configs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rustfmt/tests/target/configs')
-rw-r--r--src/tools/rustfmt/tests/target/configs/blank_lines_lower_bound/1.rs16
-rw-r--r--src/tools/rustfmt/tests/target/configs/brace_style/fn_always_next_line.rs19
-rw-r--r--src/tools/rustfmt/tests/target/configs/brace_style/fn_prefer_same_line.rs16
-rw-r--r--src/tools/rustfmt/tests/target/configs/brace_style/fn_same_line_where.rs17
-rw-r--r--src/tools/rustfmt/tests/target/configs/brace_style/item_always_next_line.rs25
-rw-r--r--src/tools/rustfmt/tests/target/configs/brace_style/item_prefer_same_line.rs18
-rw-r--r--src/tools/rustfmt/tests/target/configs/brace_style/item_same_line_where.rs19
-rw-r--r--src/tools/rustfmt/tests/target/configs/chain_width/always.rs29
-rw-r--r--src/tools/rustfmt/tests/target/configs/chain_width/small.rs32
-rw-r--r--src/tools/rustfmt/tests/target/configs/chain_width/tiny.rs26
-rw-r--r--src/tools/rustfmt/tests/target/configs/combine_control_expr/false.rs134
-rw-r--r--src/tools/rustfmt/tests/target/configs/combine_control_expr/true.rs122
-rw-r--r--src/tools/rustfmt/tests/target/configs/comment_width/above.rs8
-rw-r--r--src/tools/rustfmt/tests/target/configs/comment_width/below.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/comment_width/ignore.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/condense_wildcard_suffixes/false.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/condense_wildcard_suffixes/true.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/control_brace_style/always_next_line.rs18
-rw-r--r--src/tools/rustfmt/tests/target/configs/control_brace_style/always_same_line.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/control_brace_style/closing_next_line.rs15
-rw-r--r--src/tools/rustfmt/tests/target/configs/disable_all_formatting/false.rs10
-rw-r--r--src/tools/rustfmt/tests/target/configs/disable_all_formatting/true.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/100.rs16
-rw-r--r--src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/100_greater_max_width.rs29
-rw-r--r--src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/50.rs22
-rw-r--r--src/tools/rustfmt/tests/target/configs/empty_item_single_line/false.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/empty_item_single_line/true.rs10
-rw-r--r--src/tools/rustfmt/tests/target/configs/enum_discrim_align_threshold/40.rs34
-rw-r--r--src/tools/rustfmt/tests/target/configs/error_on_line_overflow/false.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/error_on_unformatted/false.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/fn_args_layout/compressed.rs22
-rw-r--r--src/tools/rustfmt/tests/target/configs/fn_args_layout/tall.rs32
-rw-r--r--src/tools/rustfmt/tests/target/configs/fn_args_layout/vertical.rs42
-rw-r--r--src/tools/rustfmt/tests/target/configs/fn_single_line/false.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/fn_single_line/true.rs9
-rw-r--r--src/tools/rustfmt/tests/target/configs/force_explicit_abi/false.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/force_explicit_abi/true.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/force_multiline_block/false.rs20
-rw-r--r--src/tools/rustfmt/tests/target/configs/force_multiline_block/true.rs22
-rw-r--r--src/tools/rustfmt/tests/target/configs/format_generated_files/false.rs8
-rw-r--r--src/tools/rustfmt/tests/target/configs/format_generated_files/true.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/format_macro_bodies/false.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/format_macro_bodies/true.rs10
-rw-r--r--src/tools/rustfmt/tests/target/configs/format_macro_matchers/false.rs10
-rw-r--r--src/tools/rustfmt/tests/target/configs/format_macro_matchers/true.rs10
-rw-r--r--src/tools/rustfmt/tests/target/configs/format_strings/false.rs8
-rw-r--r--src/tools/rustfmt/tests/target/configs/format_strings/true.rs9
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/One-merge_imports.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/One-nested.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/One-no_reorder.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/One.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-merge_imports.rs16
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-nested.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-no_reorder.rs15
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs18
-rw-r--r--src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate.rs13
-rw-r--r--src/tools/rustfmt/tests/target/configs/hard_tabs/false.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/hard_tabs/true.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/imports_indent/block.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/imports_layout/horizontal_vertical.rs18
-rw-r--r--src/tools/rustfmt/tests/target/configs/imports_layout/merge_mixed.rs5
-rw-r--r--src/tools/rustfmt/tests/target/configs/imports_layout/mixed.rs9
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_args.rs47
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_array.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs151
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_chain.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_generic.rs22
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_struct_lit.rs9
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_tab_spaces_call.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/one.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/two.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_where_pred.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/default.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/rfc_control.rs39
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/rfc_where.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_args.rs40
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_array.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_call.rs13
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_chain.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_generics.rs20
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_struct_lit.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_trailing_comma.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_where_pred.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/match_arm_blocks/false.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/match_arm_blocks/true.rs13
-rw-r--r--src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/always.rs27
-rw-r--r--src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/never.rs27
-rw-r--r--src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/preserve.rs35
-rw-r--r--src/tools/rustfmt/tests/target/configs/match_block_trailing_comma/false.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/match_block_trailing_comma/true.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/merge_derives/true.rs40
-rw-r--r--src/tools/rustfmt/tests/target/configs/normalize_comments/false.rs13
-rw-r--r--src/tools/rustfmt/tests/target/configs/normalize_comments/true.rs13
-rw-r--r--src/tools/rustfmt/tests/target/configs/normalize_doc_attributes/false.rs13
-rw-r--r--src/tools/rustfmt/tests/target/configs/normalize_doc_attributes/true.rs13
-rw-r--r--src/tools/rustfmt/tests/target/configs/remove_nested_parens/remove_nested_parens.rs5
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_impl_items/false.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_impl_items/true.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_imports/false.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_imports/true.rs19
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_modules/dolor/mod.rs1
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_modules/false.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_modules/ipsum/mod.rs1
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_modules/lorem/mod.rs1
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_modules/sit/mod.rs1
-rw-r--r--src/tools/rustfmt/tests/target/configs/reorder_modules/true.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/10.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/20.rs8
-rw-r--r--src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/greater_than_max_width.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/skip_children/foo/mod.rs3
-rw-r--r--src/tools/rustfmt/tests/target/configs/skip_children/true.rs4
-rw-r--r--src/tools/rustfmt/tests/target/configs/space_before_colon/true.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/spaces_around_ranges/false.rs34
-rw-r--r--src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs34
-rw-r--r--src/tools/rustfmt/tests/target/configs/struct_field_align_threshold/20.rs471
-rw-r--r--src/tools/rustfmt/tests/target/configs/struct_lit_single_line/false.rs9
-rw-r--r--src/tools/rustfmt/tests/target/configs/tab_spaces/2.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/tab_spaces/4.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/trailing_comma/always.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/trailing_comma/never.rs35
-rw-r--r--src/tools/rustfmt/tests/target/configs/trailing_comma/vertical.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/trailing_semicolon/false.rs27
-rw-r--r--src/tools/rustfmt/tests/target/configs/trailing_semicolon/true.rs27
-rw-r--r--src/tools/rustfmt/tests/target/configs/type_punctuation_density/compressed.rs41
-rw-r--r--src/tools/rustfmt/tests/target/configs/type_punctuation_density/wide.rs41
-rw-r--r--src/tools/rustfmt/tests/target/configs/use_field_init_shorthand/false.rs15
-rw-r--r--src/tools/rustfmt/tests/target/configs/use_field_init_shorthand/true.rs15
-rw-r--r--src/tools/rustfmt/tests/target/configs/use_small_heuristics/default.rs26
-rw-r--r--src/tools/rustfmt/tests/target/configs/use_small_heuristics/max.rs15
-rw-r--r--src/tools/rustfmt/tests/target/configs/use_small_heuristics/off.rs25
-rw-r--r--src/tools/rustfmt/tests/target/configs/use_try_shorthand/false.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/use_try_shorthand/true.rs6
-rw-r--r--src/tools/rustfmt/tests/target/configs/where_single_line/true-with-brace-style.rs22
-rw-r--r--src/tools/rustfmt/tests/target/configs/where_single_line/true.rs30
-rw-r--r--src/tools/rustfmt/tests/target/configs/wrap_comments/false.rs8
-rw-r--r--src/tools/rustfmt/tests/target/configs/wrap_comments/true.rs20
136 files changed, 2914 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/target/configs/blank_lines_lower_bound/1.rs b/src/tools/rustfmt/tests/target/configs/blank_lines_lower_bound/1.rs
new file mode 100644
index 000000000..9706699dc
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/blank_lines_lower_bound/1.rs
@@ -0,0 +1,16 @@
+// rustfmt-blank_lines_lower_bound: 1
+
+fn foo() {}
+
+fn bar() {}
+
+// comment
+fn foobar() {}
+
+fn foo1() {}
+
+fn bar1() {}
+
+// comment
+
+fn foobar1() {}
diff --git a/src/tools/rustfmt/tests/target/configs/brace_style/fn_always_next_line.rs b/src/tools/rustfmt/tests/target/configs/brace_style/fn_always_next_line.rs
new file mode 100644
index 000000000..2755a2646
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/brace_style/fn_always_next_line.rs
@@ -0,0 +1,19 @@
+// rustfmt-brace_style: AlwaysNextLine
+// Function brace style
+
+fn lorem()
+{
+ // body
+}
+
+fn lorem(ipsum: usize)
+{
+ // body
+}
+
+fn lorem<T>(ipsum: T)
+where
+ T: Add + Sub + Mul + Div,
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/brace_style/fn_prefer_same_line.rs b/src/tools/rustfmt/tests/target/configs/brace_style/fn_prefer_same_line.rs
new file mode 100644
index 000000000..23f98b6dd
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/brace_style/fn_prefer_same_line.rs
@@ -0,0 +1,16 @@
+// rustfmt-brace_style: PreferSameLine
+// Function brace style
+
+fn lorem() {
+ // body
+}
+
+fn lorem(ipsum: usize) {
+ // body
+}
+
+fn lorem<T>(ipsum: T)
+where
+ T: Add + Sub + Mul + Div, {
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/brace_style/fn_same_line_where.rs b/src/tools/rustfmt/tests/target/configs/brace_style/fn_same_line_where.rs
new file mode 100644
index 000000000..2afe59943
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/brace_style/fn_same_line_where.rs
@@ -0,0 +1,17 @@
+// rustfmt-brace_style: SameLineWhere
+// Function brace style
+
+fn lorem() {
+ // body
+}
+
+fn lorem(ipsum: usize) {
+ // body
+}
+
+fn lorem<T>(ipsum: T)
+where
+ T: Add + Sub + Mul + Div,
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/brace_style/item_always_next_line.rs b/src/tools/rustfmt/tests/target/configs/brace_style/item_always_next_line.rs
new file mode 100644
index 000000000..c13018630
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/brace_style/item_always_next_line.rs
@@ -0,0 +1,25 @@
+// rustfmt-brace_style: AlwaysNextLine
+// Item brace style
+
+enum Foo {}
+
+struct Bar {}
+
+struct Lorem
+{
+ ipsum: bool,
+}
+
+struct Dolor<T>
+where
+ T: Eq,
+{
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests
+{
+ #[test]
+ fn it_works() {}
+}
diff --git a/src/tools/rustfmt/tests/target/configs/brace_style/item_prefer_same_line.rs b/src/tools/rustfmt/tests/target/configs/brace_style/item_prefer_same_line.rs
new file mode 100644
index 000000000..5143d7517
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/brace_style/item_prefer_same_line.rs
@@ -0,0 +1,18 @@
+// rustfmt-brace_style: PreferSameLine
+// Item brace style
+
+struct Lorem {
+ ipsum: bool,
+}
+
+struct Dolor<T>
+where
+ T: Eq, {
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {}
+}
diff --git a/src/tools/rustfmt/tests/target/configs/brace_style/item_same_line_where.rs b/src/tools/rustfmt/tests/target/configs/brace_style/item_same_line_where.rs
new file mode 100644
index 000000000..8a3b28526
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/brace_style/item_same_line_where.rs
@@ -0,0 +1,19 @@
+// rustfmt-brace_style: SameLineWhere
+// Item brace style
+
+struct Lorem {
+ ipsum: bool,
+}
+
+struct Dolor<T>
+where
+ T: Eq,
+{
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {}
+}
diff --git a/src/tools/rustfmt/tests/target/configs/chain_width/always.rs b/src/tools/rustfmt/tests/target/configs/chain_width/always.rs
new file mode 100644
index 000000000..b16d25251
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/chain_width/always.rs
@@ -0,0 +1,29 @@
+// rustfmt-chain_width: 1
+// setting an unachievable chain_width to always get chains
+// on separate lines
+
+struct Fluent {}
+
+impl Fluent {
+ fn blorp(&self) -> &Self {
+ self
+ }
+}
+
+fn main() {
+ let test = Fluent {};
+
+ // should be left alone
+ test.blorp();
+
+ // should be wrapped
+ test.blorp()
+ .blorp();
+ test.blorp()
+ .blorp()
+ .blorp();
+ test.blorp()
+ .blorp()
+ .blorp()
+ .blorp();
+}
diff --git a/src/tools/rustfmt/tests/target/configs/chain_width/small.rs b/src/tools/rustfmt/tests/target/configs/chain_width/small.rs
new file mode 100644
index 000000000..2f2f72777
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/chain_width/small.rs
@@ -0,0 +1,32 @@
+// rustfmt-chain_width: 40
+
+struct Fluent {}
+
+impl Fluent {
+ fn blorp(&self) -> &Self {
+ self
+ }
+}
+
+fn main() {
+ let test = Fluent {};
+
+ // should not be wrapped
+ test.blorp();
+ test.blorp().blorp();
+ test.blorp().blorp().blorp();
+ test.blorp().blorp().blorp().blorp();
+
+ // should be wrapped
+ test.blorp()
+ .blorp()
+ .blorp()
+ .blorp()
+ .blorp();
+ test.blorp()
+ .blorp()
+ .blorp()
+ .blorp()
+ .blorp()
+ .blorp();
+}
diff --git a/src/tools/rustfmt/tests/target/configs/chain_width/tiny.rs b/src/tools/rustfmt/tests/target/configs/chain_width/tiny.rs
new file mode 100644
index 000000000..960d245f8
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/chain_width/tiny.rs
@@ -0,0 +1,26 @@
+// rustfmt-chain_width: 20
+
+struct Fluent {}
+
+impl Fluent {
+ fn blorp(&self) -> &Self {
+ self
+ }
+}
+
+fn main() {
+ let test = Fluent {};
+
+ // should not be wrapped
+ test.blorp();
+ test.blorp().blorp();
+
+ // should be wrapped
+ test.blorp()
+ .blorp()
+ .blorp();
+ test.blorp()
+ .blorp()
+ .blorp()
+ .blorp();
+}
diff --git a/src/tools/rustfmt/tests/target/configs/combine_control_expr/false.rs b/src/tools/rustfmt/tests/target/configs/combine_control_expr/false.rs
new file mode 100644
index 000000000..5ada9b1dd
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/combine_control_expr/false.rs
@@ -0,0 +1,134 @@
+// rustfmt-indent_style: Block
+// rustfmt-combine_control_expr: false
+
+// Combining openings and closings. See rust-lang/fmt-rfcs#61.
+
+fn main() {
+ // Call
+ foo(bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Mac
+ foo(foo!(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // MethodCall
+ foo(x.foo::<Bar, Baz>(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Block
+ foo!({
+ foo();
+ bar();
+ });
+
+ // Closure
+ foo(|x| {
+ let y = x + 1;
+ y
+ });
+
+ // Match
+ foo(match opt {
+ Some(x) => x,
+ None => y,
+ });
+
+ // Struct
+ foo(Bar {
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ });
+
+ // If
+ foo!(
+ if x {
+ foo();
+ } else {
+ bar();
+ }
+ );
+
+ // IfLet
+ foo!(
+ if let Some(..) = x {
+ foo();
+ } else {
+ bar();
+ }
+ );
+
+ // While
+ foo!(
+ while x {
+ foo();
+ bar();
+ }
+ );
+
+ // WhileLet
+ foo!(
+ while let Some(..) = x {
+ foo();
+ bar();
+ }
+ );
+
+ // ForLoop
+ foo!(
+ for x in y {
+ foo();
+ bar();
+ }
+ );
+
+ // Loop
+ foo!(
+ loop {
+ foo();
+ bar();
+ }
+ );
+
+ // Tuple
+ foo((
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // AddrOf
+ foo(&bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Box
+ foo(box Bar {
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ });
+
+ // Unary
+ foo(!bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Try
+ foo(bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ )?);
+
+ // Cast
+ foo(Bar {
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ } as i64);
+}
diff --git a/src/tools/rustfmt/tests/target/configs/combine_control_expr/true.rs b/src/tools/rustfmt/tests/target/configs/combine_control_expr/true.rs
new file mode 100644
index 000000000..52acd2649
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/combine_control_expr/true.rs
@@ -0,0 +1,122 @@
+// rustfmt-indent_style: Block
+// rustfmt-combine_control_expr: true
+
+// Combining openings and closings. See rust-lang/fmt-rfcs#61.
+
+fn main() {
+ // Call
+ foo(bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Mac
+ foo(foo!(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // MethodCall
+ foo(x.foo::<Bar, Baz>(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Block
+ foo!({
+ foo();
+ bar();
+ });
+
+ // Closure
+ foo(|x| {
+ let y = x + 1;
+ y
+ });
+
+ // Match
+ foo(match opt {
+ Some(x) => x,
+ None => y,
+ });
+
+ // Struct
+ foo(Bar {
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ });
+
+ // If
+ foo!(if x {
+ foo();
+ } else {
+ bar();
+ });
+
+ // IfLet
+ foo!(if let Some(..) = x {
+ foo();
+ } else {
+ bar();
+ });
+
+ // While
+ foo!(while x {
+ foo();
+ bar();
+ });
+
+ // WhileLet
+ foo!(while let Some(..) = x {
+ foo();
+ bar();
+ });
+
+ // ForLoop
+ foo!(for x in y {
+ foo();
+ bar();
+ });
+
+ // Loop
+ foo!(loop {
+ foo();
+ bar();
+ });
+
+ // Tuple
+ foo((
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // AddrOf
+ foo(&bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Box
+ foo(box Bar {
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ });
+
+ // Unary
+ foo(!bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Try
+ foo(bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ )?);
+
+ // Cast
+ foo(Bar {
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ } as i64);
+}
diff --git a/src/tools/rustfmt/tests/target/configs/comment_width/above.rs b/src/tools/rustfmt/tests/target/configs/comment_width/above.rs
new file mode 100644
index 000000000..ddfecda65
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/comment_width/above.rs
@@ -0,0 +1,8 @@
+// rustfmt-comment_width: 40
+// rustfmt-wrap_comments: true
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet,
+ // consectetur adipiscing elit.
+}
diff --git a/src/tools/rustfmt/tests/target/configs/comment_width/below.rs b/src/tools/rustfmt/tests/target/configs/comment_width/below.rs
new file mode 100644
index 000000000..abbc5930c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/comment_width/below.rs
@@ -0,0 +1,7 @@
+// rustfmt-comment_width: 80
+// rustfmt-wrap_comments: true
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+}
diff --git a/src/tools/rustfmt/tests/target/configs/comment_width/ignore.rs b/src/tools/rustfmt/tests/target/configs/comment_width/ignore.rs
new file mode 100644
index 000000000..c86e71c28
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/comment_width/ignore.rs
@@ -0,0 +1,7 @@
+// rustfmt-comment_width: 40
+// rustfmt-wrap_comments: false
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+}
diff --git a/src/tools/rustfmt/tests/target/configs/condense_wildcard_suffixes/false.rs b/src/tools/rustfmt/tests/target/configs/condense_wildcard_suffixes/false.rs
new file mode 100644
index 000000000..3b967f35a
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/condense_wildcard_suffixes/false.rs
@@ -0,0 +1,6 @@
+// rustfmt-condense_wildcard_suffixes: false
+// Condense wildcard suffixes
+
+fn main() {
+ let (lorem, ipsum, _, _) = (1, 2, 3, 4);
+}
diff --git a/src/tools/rustfmt/tests/target/configs/condense_wildcard_suffixes/true.rs b/src/tools/rustfmt/tests/target/configs/condense_wildcard_suffixes/true.rs
new file mode 100644
index 000000000..4f880abe8
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/condense_wildcard_suffixes/true.rs
@@ -0,0 +1,6 @@
+// rustfmt-condense_wildcard_suffixes: true
+// Condense wildcard suffixes
+
+fn main() {
+ let (lorem, ipsum, ..) = (1, 2, 3, 4);
+}
diff --git a/src/tools/rustfmt/tests/target/configs/control_brace_style/always_next_line.rs b/src/tools/rustfmt/tests/target/configs/control_brace_style/always_next_line.rs
new file mode 100644
index 000000000..7dc06f207
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/control_brace_style/always_next_line.rs
@@ -0,0 +1,18 @@
+// rustfmt-control_brace_style: AlwaysNextLine
+// Control brace style
+
+fn main() {
+ if lorem
+ {
+ println!("ipsum!");
+ }
+ else
+ {
+ println!("dolor!");
+ }
+ match magi
+ {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/control_brace_style/always_same_line.rs b/src/tools/rustfmt/tests/target/configs/control_brace_style/always_same_line.rs
new file mode 100644
index 000000000..993b6b681
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/control_brace_style/always_same_line.rs
@@ -0,0 +1,14 @@
+// rustfmt-control_brace_style: AlwaysSameLine
+// Control brace style
+
+fn main() {
+ if lorem {
+ println!("ipsum!");
+ } else {
+ println!("dolor!");
+ }
+ match magi {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/control_brace_style/closing_next_line.rs b/src/tools/rustfmt/tests/target/configs/control_brace_style/closing_next_line.rs
new file mode 100644
index 000000000..013852ee7
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/control_brace_style/closing_next_line.rs
@@ -0,0 +1,15 @@
+// rustfmt-control_brace_style: ClosingNextLine
+// Control brace style
+
+fn main() {
+ if lorem {
+ println!("ipsum!");
+ }
+ else {
+ println!("dolor!");
+ }
+ match magi {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/disable_all_formatting/false.rs b/src/tools/rustfmt/tests/target/configs/disable_all_formatting/false.rs
new file mode 100644
index 000000000..1a0477ddb
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/disable_all_formatting/false.rs
@@ -0,0 +1,10 @@
+// rustfmt-disable_all_formatting: false
+// Disable all formatting
+
+fn main() {
+ if lorem {
+ println!("ipsum!");
+ } else {
+ println!("dolor!");
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/disable_all_formatting/true.rs b/src/tools/rustfmt/tests/target/configs/disable_all_formatting/true.rs
new file mode 100644
index 000000000..736ccf569
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/disable_all_formatting/true.rs
@@ -0,0 +1,6 @@
+// rustfmt-disable_all_formatting: true
+// Disable all formatting
+
+fn main() {
+ if lorem{println!("ipsum!");}else{println!("dolor!");}
+}
diff --git a/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/100.rs b/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/100.rs
new file mode 100644
index 000000000..c010a28aa
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/100.rs
@@ -0,0 +1,16 @@
+// rustfmt-format_code_in_doc_comments: true
+// rustfmt-doc_comment_code_block_width: 100
+
+/// ```rust
+/// impl Test {
+/// pub const fn from_bytes(v: &[u8]) -> Result<Self, ParserError> {
+/// Self::from_bytes_manual_slice(v, 0, v.len())
+/// }
+/// }
+/// ```
+
+impl Test {
+ pub const fn from_bytes(v: &[u8]) -> Result<Self, ParserError> {
+ Self::from_bytes_manual_slice(v, 0, v.len())
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/100_greater_max_width.rs b/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/100_greater_max_width.rs
new file mode 100644
index 000000000..6bcb99b91
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/100_greater_max_width.rs
@@ -0,0 +1,29 @@
+// rustfmt-max_width: 50
+// rustfmt-format_code_in_doc_comments: true
+// rustfmt-doc_comment_code_block_width: 100
+
+/// ```rust
+/// impl Test {
+/// pub const fn from_bytes(
+/// v: &[u8],
+/// ) -> Result<Self, ParserError> {
+/// Self::from_bytes_manual_slice(
+/// v,
+/// 0,
+/// v.len(),
+/// )
+/// }
+/// }
+/// ```
+
+impl Test {
+ pub const fn from_bytes(
+ v: &[u8],
+ ) -> Result<Self, ParserError> {
+ Self::from_bytes_manual_slice(
+ v,
+ 0,
+ v.len(),
+ )
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/50.rs b/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/50.rs
new file mode 100644
index 000000000..e8ab6f28b
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/doc_comment_code_block_width/50.rs
@@ -0,0 +1,22 @@
+// rustfmt-format_code_in_doc_comments: true
+// rustfmt-doc_comment_code_block_width: 50
+
+/// ```rust
+/// impl Test {
+/// pub const fn from_bytes(
+/// v: &[u8],
+/// ) -> Result<Self, ParserError> {
+/// Self::from_bytes_manual_slice(
+/// v,
+/// 0,
+/// v.len(),
+/// )
+/// }
+/// }
+/// ```
+
+impl Test {
+ pub const fn from_bytes(v: &[u8]) -> Result<Self, ParserError> {
+ Self::from_bytes_manual_slice(v, 0, v.len())
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/empty_item_single_line/false.rs b/src/tools/rustfmt/tests/target/configs/empty_item_single_line/false.rs
new file mode 100644
index 000000000..174fe330a
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/empty_item_single_line/false.rs
@@ -0,0 +1,14 @@
+// rustfmt-empty_item_single_line: false
+// Empty impl on single line
+
+impl Lorem {
+}
+
+impl Ipsum {
+}
+
+fn lorem() {
+}
+
+fn lorem() {
+}
diff --git a/src/tools/rustfmt/tests/target/configs/empty_item_single_line/true.rs b/src/tools/rustfmt/tests/target/configs/empty_item_single_line/true.rs
new file mode 100644
index 000000000..0755485fe
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/empty_item_single_line/true.rs
@@ -0,0 +1,10 @@
+// rustfmt-empty_item_single_line: true
+// Empty impl on single line
+
+impl Lorem {}
+
+impl Ipsum {}
+
+fn lorem() {}
+
+fn lorem() {}
diff --git a/src/tools/rustfmt/tests/target/configs/enum_discrim_align_threshold/40.rs b/src/tools/rustfmt/tests/target/configs/enum_discrim_align_threshold/40.rs
new file mode 100644
index 000000000..3ed66039c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/enum_discrim_align_threshold/40.rs
@@ -0,0 +1,34 @@
+// rustfmt-enum_discrim_align_threshold: 40
+
+enum Standard {
+ A = 1,
+ Bcdef = 2,
+}
+
+enum NoDiscrims {
+ ThisIsAFairlyLongEnumVariantWithoutDiscrimLongerThan40,
+ A = 1,
+ ThisIsAnotherFairlyLongEnumVariantWithoutDiscrimLongerThan40,
+ Bcdef = 2,
+}
+
+enum TooLong {
+ ThisOneHasDiscrimAaaaaaaaaaaaaaaaaaaaaaChar40 = 10,
+ A = 1,
+ Bcdef = 2,
+}
+
+enum Borderline {
+ ThisOneHasDiscrimAaaaaaaaaaaaaaaaaaaaaa = 10,
+ A = 1,
+ Bcdef = 2,
+}
+
+// Live specimen from #1686
+enum LongWithSmallDiff {
+ SceneColorimetryEstimates = 0x73636F65,
+ SceneAppearanceEstimates = 0x73617065,
+ FocalPlaneColorimetryEstimates = 0x66706365,
+ ReflectionHardcopyOriginalColorimetry = 0x72686F63,
+ ReflectionPrintOutputColorimetry = 0x72706F63,
+}
diff --git a/src/tools/rustfmt/tests/target/configs/error_on_line_overflow/false.rs b/src/tools/rustfmt/tests/target/configs/error_on_line_overflow/false.rs
new file mode 100644
index 000000000..fa70ae783
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/error_on_line_overflow/false.rs
@@ -0,0 +1,6 @@
+// rustfmt-error_on_line_overflow: false
+// Error on line overflow
+
+fn main() {
+ let lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit_lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/error_on_unformatted/false.rs b/src/tools/rustfmt/tests/target/configs/error_on_unformatted/false.rs
new file mode 100644
index 000000000..6a78374e2
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/error_on_unformatted/false.rs
@@ -0,0 +1,12 @@
+// rustfmt-error_on_unformatted: false
+// Error on line overflow comment or string literals.
+
+// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+fn main() {
+ // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+ let x = " ";
+ let a = "
+
+";
+}
diff --git a/src/tools/rustfmt/tests/target/configs/fn_args_layout/compressed.rs b/src/tools/rustfmt/tests/target/configs/fn_args_layout/compressed.rs
new file mode 100644
index 000000000..f189446e2
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/fn_args_layout/compressed.rs
@@ -0,0 +1,22 @@
+// rustfmt-fn_args_layout: Compressed
+// Function arguments density
+
+trait Lorem {
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
+ // body
+ }
+
+ fn lorem(
+ ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur,
+ adipiscing: Adipiscing, elit: Elit,
+ );
+
+ fn lorem(
+ ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur,
+ adipiscing: Adipiscing, elit: Elit,
+ ) {
+ // body
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/fn_args_layout/tall.rs b/src/tools/rustfmt/tests/target/configs/fn_args_layout/tall.rs
new file mode 100644
index 000000000..20f308973
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/fn_args_layout/tall.rs
@@ -0,0 +1,32 @@
+// rustfmt-fn_args_layout: Tall
+// Function arguments density
+
+trait Lorem {
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
+ // body
+ }
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: onsectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
+ );
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: onsectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
+ ) {
+ // body
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/fn_args_layout/vertical.rs b/src/tools/rustfmt/tests/target/configs/fn_args_layout/vertical.rs
new file mode 100644
index 000000000..6c695a75d
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/fn_args_layout/vertical.rs
@@ -0,0 +1,42 @@
+// rustfmt-fn_args_layout: Vertical
+// Function arguments density
+
+trait Lorem {
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ );
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ ) {
+ // body
+ }
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: onsectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
+ );
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: onsectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
+ ) {
+ // body
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/fn_single_line/false.rs b/src/tools/rustfmt/tests/target/configs/fn_single_line/false.rs
new file mode 100644
index 000000000..3d092f0c0
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/fn_single_line/false.rs
@@ -0,0 +1,11 @@
+// rustfmt-fn_single_line: false
+// Single-expression function on single line
+
+fn lorem() -> usize {
+ 42
+}
+
+fn lorem() -> usize {
+ let ipsum = 42;
+ ipsum
+}
diff --git a/src/tools/rustfmt/tests/target/configs/fn_single_line/true.rs b/src/tools/rustfmt/tests/target/configs/fn_single_line/true.rs
new file mode 100644
index 000000000..10d94e02f
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/fn_single_line/true.rs
@@ -0,0 +1,9 @@
+// rustfmt-fn_single_line: true
+// Single-expression function on single line
+
+fn lorem() -> usize { 42 }
+
+fn lorem() -> usize {
+ let ipsum = 42;
+ ipsum
+}
diff --git a/src/tools/rustfmt/tests/target/configs/force_explicit_abi/false.rs b/src/tools/rustfmt/tests/target/configs/force_explicit_abi/false.rs
new file mode 100644
index 000000000..3c48f8e0c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/force_explicit_abi/false.rs
@@ -0,0 +1,6 @@
+// rustfmt-force_explicit_abi: false
+// Force explicit abi
+
+extern {
+ pub static lorem: c_int;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/force_explicit_abi/true.rs b/src/tools/rustfmt/tests/target/configs/force_explicit_abi/true.rs
new file mode 100644
index 000000000..90f5a8c4e
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/force_explicit_abi/true.rs
@@ -0,0 +1,6 @@
+// rustfmt-force_explicit_abi: true
+// Force explicit abi
+
+extern "C" {
+ pub static lorem: c_int;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/force_multiline_block/false.rs b/src/tools/rustfmt/tests/target/configs/force_multiline_block/false.rs
new file mode 100644
index 000000000..7cb4cac1d
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/force_multiline_block/false.rs
@@ -0,0 +1,20 @@
+// rustfmt-force_multiline_blocks: false
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ if ipsum {
+ println!("dolor");
+ }
+ }
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ });
+}
diff --git a/src/tools/rustfmt/tests/target/configs/force_multiline_block/true.rs b/src/tools/rustfmt/tests/target/configs/force_multiline_block/true.rs
new file mode 100644
index 000000000..aec50afe5
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/force_multiline_block/true.rs
@@ -0,0 +1,22 @@
+// rustfmt-force_multiline_blocks: true
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ if ipsum {
+ println!("dolor");
+ }
+ }
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| {
+ match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ }
+ });
+}
diff --git a/src/tools/rustfmt/tests/target/configs/format_generated_files/false.rs b/src/tools/rustfmt/tests/target/configs/format_generated_files/false.rs
new file mode 100644
index 000000000..dec1e00d1
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/format_generated_files/false.rs
@@ -0,0 +1,8 @@
+// @generated
+// rustfmt-format_generated_files: false
+
+fn main()
+{
+ println!("hello, world")
+ ;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/format_generated_files/true.rs b/src/tools/rustfmt/tests/target/configs/format_generated_files/true.rs
new file mode 100644
index 000000000..5fea7e8b3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/format_generated_files/true.rs
@@ -0,0 +1,6 @@
+// @generated
+// rustfmt-format_generated_files: true
+
+fn main() {
+ println!("hello, world");
+}
diff --git a/src/tools/rustfmt/tests/target/configs/format_macro_bodies/false.rs b/src/tools/rustfmt/tests/target/configs/format_macro_bodies/false.rs
new file mode 100644
index 000000000..ec871b25b
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/format_macro_bodies/false.rs
@@ -0,0 +1,6 @@
+// rustfmt-format_macro_bodies: false
+
+macro_rules! foo {
+ ($a: ident : $b: ty) => { $a(42): $b; };
+ ($a: ident $b: ident $c: ident) => { $a=$b+$c; };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/format_macro_bodies/true.rs b/src/tools/rustfmt/tests/target/configs/format_macro_bodies/true.rs
new file mode 100644
index 000000000..9dc2524c3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/format_macro_bodies/true.rs
@@ -0,0 +1,10 @@
+// rustfmt-format_macro_bodies: true
+
+macro_rules! foo {
+ ($a: ident : $b: ty) => {
+ $a(42): $b;
+ };
+ ($a: ident $b: ident $c: ident) => {
+ $a = $b + $c;
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/format_macro_matchers/false.rs b/src/tools/rustfmt/tests/target/configs/format_macro_matchers/false.rs
new file mode 100644
index 000000000..3966d21be
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/format_macro_matchers/false.rs
@@ -0,0 +1,10 @@
+// rustfmt-format_macro_matchers: false
+
+macro_rules! foo {
+ ($a: ident : $b: ty) => {
+ $a(42): $b;
+ };
+ ($a: ident $b: ident $c: ident) => {
+ $a = $b + $c;
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/format_macro_matchers/true.rs b/src/tools/rustfmt/tests/target/configs/format_macro_matchers/true.rs
new file mode 100644
index 000000000..e113af96f
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/format_macro_matchers/true.rs
@@ -0,0 +1,10 @@
+// rustfmt-format_macro_matchers: true
+
+macro_rules! foo {
+ ($a:ident : $b:ty) => {
+ $a(42): $b;
+ };
+ ($a:ident $b:ident $c:ident) => {
+ $a = $b + $c;
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/format_strings/false.rs b/src/tools/rustfmt/tests/target/configs/format_strings/false.rs
new file mode 100644
index 000000000..ecca0d7d1
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/format_strings/false.rs
@@ -0,0 +1,8 @@
+// rustfmt-format_strings: false
+// rustfmt-max_width: 50
+// rustfmt-error_on_line_overflow: false
+// Force format strings
+
+fn main() {
+ let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
+}
diff --git a/src/tools/rustfmt/tests/target/configs/format_strings/true.rs b/src/tools/rustfmt/tests/target/configs/format_strings/true.rs
new file mode 100644
index 000000000..fdd5ab2c9
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/format_strings/true.rs
@@ -0,0 +1,9 @@
+// rustfmt-format_strings: true
+// rustfmt-max_width: 50
+// Force format strings
+
+fn main() {
+ let lorem = "ipsum dolor sit amet \
+ consectetur adipiscing elit \
+ lorem ipsum dolor sit";
+}
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/One-merge_imports.rs b/src/tools/rustfmt/tests/target/configs/group_imports/One-merge_imports.rs
new file mode 100644
index 000000000..52e0e1c5a
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/One-merge_imports.rs
@@ -0,0 +1,14 @@
+// rustfmt-group_imports: One
+// rustfmt-imports_granularity: Crate
+use super::{
+ schema::{Context, Payload},
+ update::convert_publish_payload,
+};
+use crate::models::Event;
+use alloc::{alloc::Layout, vec::Vec};
+use broker::database::PooledConnection;
+use chrono::Utc;
+use core::f32;
+use juniper::{FieldError, FieldResult};
+use std::sync::Arc;
+use uuid::Uuid;
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/One-nested.rs b/src/tools/rustfmt/tests/target/configs/group_imports/One-nested.rs
new file mode 100644
index 000000000..5b6485482
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/One-nested.rs
@@ -0,0 +1,6 @@
+// rustfmt-group_imports: One
+mod test {
+ use crate::foo::bar;
+ use crate::foo::bar2;
+ use std::path;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/One-no_reorder.rs b/src/tools/rustfmt/tests/target/configs/group_imports/One-no_reorder.rs
new file mode 100644
index 000000000..015e841d0
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/One-no_reorder.rs
@@ -0,0 +1,12 @@
+// rustfmt-group_imports: One
+// rustfmt-reorder_imports: false
+use chrono::Utc;
+use super::update::convert_publish_payload;
+use juniper::{FieldError, FieldResult};
+use uuid::Uuid;
+use alloc::alloc::Layout;
+use std::sync::Arc;
+use broker::database::PooledConnection;
+use super::schema::{Context, Payload};
+use core::f32;
+use crate::models::Event;
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/One.rs b/src/tools/rustfmt/tests/target/configs/group_imports/One.rs
new file mode 100644
index 000000000..3094c7ae1
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/One.rs
@@ -0,0 +1,11 @@
+// rustfmt-group_imports: One
+use super::schema::{Context, Payload};
+use super::update::convert_publish_payload;
+use crate::models::Event;
+use alloc::alloc::Layout;
+use broker::database::PooledConnection;
+use chrono::Utc;
+use core::f32;
+use juniper::{FieldError, FieldResult};
+use std::sync::Arc;
+use uuid::Uuid;
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-merge_imports.rs b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-merge_imports.rs
new file mode 100644
index 000000000..5e4064dd8
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-merge_imports.rs
@@ -0,0 +1,16 @@
+// rustfmt-group_imports: StdExternalCrate
+// rustfmt-imports_granularity: Crate
+use alloc::{alloc::Layout, vec::Vec};
+use core::f32;
+use std::sync::Arc;
+
+use broker::database::PooledConnection;
+use chrono::Utc;
+use juniper::{FieldError, FieldResult};
+use uuid::Uuid;
+
+use super::{
+ schema::{Context, Payload},
+ update::convert_publish_payload,
+};
+use crate::models::Event;
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-nested.rs b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-nested.rs
new file mode 100644
index 000000000..daf23375c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-nested.rs
@@ -0,0 +1,7 @@
+// rustfmt-group_imports: StdExternalCrate
+mod test {
+ use std::path;
+
+ use crate::foo::bar;
+ use crate::foo::bar2;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-no_reorder.rs b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-no_reorder.rs
new file mode 100644
index 000000000..76d3d6ccb
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-no_reorder.rs
@@ -0,0 +1,15 @@
+// rustfmt-group_imports: StdExternalCrate
+// rustfmt-reorder_imports: false
+
+use alloc::alloc::Layout;
+use std::sync::Arc;
+use core::f32;
+
+use chrono::Utc;
+use juniper::{FieldError, FieldResult};
+use uuid::Uuid;
+use broker::database::PooledConnection;
+
+use super::update::convert_publish_payload;
+use super::schema::{Context, Payload};
+use crate::models::Event;
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs
new file mode 100644
index 000000000..ecc8ede02
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs
@@ -0,0 +1,18 @@
+// rustfmt-group_imports: StdExternalCrate
+use alloc::alloc::Layout;
+
+use chrono::Utc;
+use juniper::{FieldError, FieldResult};
+use uuid::Uuid;
+
+use super::update::convert_publish_payload;
+
+extern crate uuid;
+
+use core::f32;
+use std::sync::Arc;
+
+use broker::database::PooledConnection;
+
+use super::schema::{Context, Payload};
+use crate::models::Event;
diff --git a/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate.rs b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate.rs
new file mode 100644
index 000000000..080257968
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/group_imports/StdExternalCrate.rs
@@ -0,0 +1,13 @@
+// rustfmt-group_imports: StdExternalCrate
+use alloc::alloc::Layout;
+use core::f32;
+use std::sync::Arc;
+
+use broker::database::PooledConnection;
+use chrono::Utc;
+use juniper::{FieldError, FieldResult};
+use uuid::Uuid;
+
+use super::schema::{Context, Payload};
+use super::update::convert_publish_payload;
+use crate::models::Event;
diff --git a/src/tools/rustfmt/tests/target/configs/hard_tabs/false.rs b/src/tools/rustfmt/tests/target/configs/hard_tabs/false.rs
new file mode 100644
index 000000000..ccfb53d8c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/hard_tabs/false.rs
@@ -0,0 +1,6 @@
+// rustfmt-hard_tabs: false
+// Hard tabs
+
+fn lorem() -> usize {
+ 42 // spaces before 42
+}
diff --git a/src/tools/rustfmt/tests/target/configs/hard_tabs/true.rs b/src/tools/rustfmt/tests/target/configs/hard_tabs/true.rs
new file mode 100644
index 000000000..3ed4e4f20
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/hard_tabs/true.rs
@@ -0,0 +1,6 @@
+// rustfmt-hard_tabs: true
+// Hard tabs
+
+fn lorem() -> usize {
+ 42 // spaces before 42
+}
diff --git a/src/tools/rustfmt/tests/target/configs/imports_indent/block.rs b/src/tools/rustfmt/tests/target/configs/imports_indent/block.rs
new file mode 100644
index 000000000..84c3b26bd
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/imports_indent/block.rs
@@ -0,0 +1,7 @@
+// rustfmt-imports_indent: Block
+
+use lists::{
+ definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
+ struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting, ListItem, ListTactic,
+ SeparatorTactic,
+};
diff --git a/src/tools/rustfmt/tests/target/configs/imports_layout/horizontal_vertical.rs b/src/tools/rustfmt/tests/target/configs/imports_layout/horizontal_vertical.rs
new file mode 100644
index 000000000..4a63556d4
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/imports_layout/horizontal_vertical.rs
@@ -0,0 +1,18 @@
+// rustfmt-imports_indent: Block
+// rustfmt-imports_layout: HorizontalVertical
+
+use comment::{contains_comment, recover_comment_removed, rewrite_comment, FindUncommented};
+use lists::{
+ definitive_tactic,
+ itemize_list,
+ shape_for_tactic,
+ struct_lit_formatting,
+ struct_lit_shape,
+ struct_lit_tactic,
+ write_list,
+ DefinitiveListTactic,
+ ListFormatting,
+ ListItem,
+ ListTactic,
+ SeparatorTactic,
+};
diff --git a/src/tools/rustfmt/tests/target/configs/imports_layout/merge_mixed.rs b/src/tools/rustfmt/tests/target/configs/imports_layout/merge_mixed.rs
new file mode 100644
index 000000000..bc0da92ff
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/imports_layout/merge_mixed.rs
@@ -0,0 +1,5 @@
+// rustfmt-imports_indent: Block
+// rustfmt-imports_granularity: Crate
+// rustfmt-imports_layout: Mixed
+
+use std::{fmt, io, str, str::FromStr};
diff --git a/src/tools/rustfmt/tests/target/configs/imports_layout/mixed.rs b/src/tools/rustfmt/tests/target/configs/imports_layout/mixed.rs
new file mode 100644
index 000000000..5d3349a01
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/imports_layout/mixed.rs
@@ -0,0 +1,9 @@
+// rustfmt-imports_indent: Block
+// rustfmt-imports_layout: Mixed
+
+use comment::{contains_comment, recover_comment_removed, rewrite_comment, FindUncommented};
+use lists::{
+ definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
+ struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting, ListItem, ListTactic,
+ SeparatorTactic,
+};
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_args.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_args.rs
new file mode 100644
index 000000000..80f4e1333
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_args.rs
@@ -0,0 +1,47 @@
+// rustfmt-indent_style: Block
+// Function arguments layout
+
+fn lorem() {}
+
+fn lorem(ipsum: usize) {}
+
+fn lorem(
+ ipsum: usize,
+ dolor: usize,
+ sit: usize,
+ amet: usize,
+ consectetur: usize,
+ adipiscing: usize,
+ elit: usize,
+) {
+ // body
+}
+
+// #1441
+extern "system" {
+ pub fn GetConsoleHistoryInfo(
+ console_history_info: *mut ConsoleHistoryInfo,
+ ) -> Boooooooooooooool;
+}
+
+// rustfmt should not add trailing comma for variadic function. See #1623.
+extern "C" {
+ pub fn variadic_fn(
+ first_parameter: FirstParameterType,
+ second_parameter: SecondParameterType,
+ ...
+ );
+}
+
+// #1652
+fn deconstruct(
+ foo: Bar,
+) -> (
+ SocketAddr,
+ Header,
+ Method,
+ RequestUri,
+ HttpVersion,
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+) {
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_array.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_array.rs
new file mode 100644
index 000000000..5d458248c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_array.rs
@@ -0,0 +1,14 @@
+// rustfmt-indent_style: Block
+// Array layout
+
+fn main() {
+ let lorem = vec![
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit",
+ ];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs
new file mode 100644
index 000000000..19c44dc01
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs
@@ -0,0 +1,151 @@
+// rustfmt-indent_style: Block
+// Function call style
+
+fn main() {
+ lorem(
+ "lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit",
+ );
+ // #1501
+ let hyper = Arc::new(Client::with_connector(
+ HttpsConnector::new(TlsClient::new()),
+ ));
+
+ // chain
+ let x = yooooooooooooo
+ .fooooooooooooooo
+ .baaaaaaaaaaaaar(hello, world);
+
+ // #1380
+ {
+ {
+ let creds = self
+ .client
+ .client_credentials(&self.config.auth.oauth2.id, &self.config.auth.oauth2.secret)?;
+ }
+ }
+
+ // nesting macro and function call
+ try!(foo(
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ ));
+ try!(foo(try!(
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ )));
+}
+
+// #1521
+impl Foo {
+ fn map_pixel_to_coords(&self, point: &Vector2i, view: &View) -> Vector2f {
+ unsafe {
+ Vector2f::from_raw(ffi::sfRenderTexture_mapPixelToCoords(
+ self.render_texture,
+ point.raw(),
+ view.raw(),
+ ))
+ }
+ }
+}
+
+fn issue1420() {
+ given(
+ r#"
+ # Getting started
+ ...
+ "#,
+ )
+ .running(waltz)
+}
+
+// #1563
+fn query(conn: &Connection) -> Result<()> {
+ conn.query_row(
+ r#"
+ SELECT title, date
+ FROM posts,
+ WHERE DATE(date) = $1
+ "#,
+ &[],
+ |row| Post {
+ title: row.get(0),
+ date: row.get(1),
+ },
+ )?;
+
+ Ok(())
+}
+
+// #1449
+fn future_rayon_wait_1_thread() {
+ // run with only 1 worker thread; this would deadlock if we couldn't make progress
+ let mut result = None;
+ ThreadPool::new(Configuration::new().num_threads(1))
+ .unwrap()
+ .install(|| {
+ scope(|s| {
+ use std::sync::mpsc::channel;
+ let (tx, rx) = channel();
+ let a = s.spawn_future(lazy(move || Ok::<usize, ()>(rx.recv().unwrap())));
+ // ^^^^ FIXME: why is this needed?
+ let b = s.spawn_future(a.map(|v| v + 1));
+ let c = s.spawn_future(b.map(|v| v + 1));
+ s.spawn(move |_| tx.send(20).unwrap());
+ result = Some(c.rayon_wait().unwrap());
+ });
+ });
+ assert_eq!(result, Some(22));
+}
+
+// #1494
+impl Cursor {
+ fn foo() {
+ self.cur_type()
+ .num_template_args()
+ .or_else(|| {
+ let n: c_int = unsafe { clang_Cursor_getNumTemplateArguments(self.x) };
+
+ if n >= 0 {
+ Some(n as u32)
+ } else {
+ debug_assert_eq!(n, -1);
+ None
+ }
+ })
+ .or_else(|| {
+ let canonical = self.canonical();
+ if canonical != *self {
+ canonical.num_template_args()
+ } else {
+ None
+ }
+ });
+ }
+}
+
+fn issue1581() {
+ bootstrap.checks.register("PERSISTED_LOCATIONS", move || {
+ if locations2.0.inner_mut.lock().poisoned {
+ Check::new(
+ State::Error,
+ "Persisted location storage is poisoned due to a write failure",
+ )
+ } else {
+ Check::new(State::Healthy, "Persisted location storage is healthy")
+ }
+ });
+}
+
+fn issue1651() {
+ {
+ let type_list: Vec<_> =
+ try_opt!(types.iter().map(|ty| ty.rewrite(context, shape)).collect());
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_chain.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_chain.rs
new file mode 100644
index 000000000..23340a4ab
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_chain.rs
@@ -0,0 +1,12 @@
+// rustfmt-indent_style: Block
+// Chain indent
+
+fn main() {
+ let lorem = ipsum
+ .dolor()
+ .sit()
+ .amet()
+ .consectetur()
+ .adipiscing()
+ .elite();
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_generic.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_generic.rs
new file mode 100644
index 000000000..c4fcaaf65
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_generic.rs
@@ -0,0 +1,22 @@
+// rustfmt-indent_style: Block
+// Generics indent
+
+fn lorem<
+ Ipsum: Eq = usize,
+ Dolor: Eq = usize,
+ Sit: Eq = usize,
+ Amet: Eq = usize,
+ Adipiscing: Eq = usize,
+ Consectetur: Eq = usize,
+ Elit: Eq = usize,
+>(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ adipiscing: Adipiscing,
+ consectetur: Consectetur,
+ elit: Elit,
+) -> T {
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_struct_lit.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_struct_lit.rs
new file mode 100644
index 000000000..656b56226
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_struct_lit.rs
@@ -0,0 +1,9 @@
+// rustfmt-indent_style: Block
+// Struct literal-style
+
+fn main() {
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_tab_spaces_call.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_tab_spaces_call.rs
new file mode 100644
index 000000000..5531e61dd
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_tab_spaces_call.rs
@@ -0,0 +1,14 @@
+// rustfmt-indent_style: Block
+// rustfmt-max_width: 80
+// rustfmt-tab_spaces: 2
+
+// #1427
+fn main() {
+ exceptaions::config(move || {
+ (
+ NmiConfig {},
+ HardFaultConfig {},
+ SysTickConfig { gpio_sbsrr },
+ )
+ });
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/one.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/one.rs
new file mode 100644
index 000000000..6b9489bef
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/one.rs
@@ -0,0 +1,12 @@
+// rustfmt-version: One
+// rustfmt-error_on_line_overflow: false
+// rustfmt-indent_style: Block
+
+// rustfmt should not add trailing comma when rewriting macro. See #1528.
+fn a() {
+ panic!("this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:");
+ foo(
+ a,
+ oooptoptoptoptptooptoptoptoptptooptoptoptoptptoptoptoptoptpt(),
+ );
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/two.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/two.rs
new file mode 100644
index 000000000..4f4292e5f
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/two.rs
@@ -0,0 +1,14 @@
+// rustfmt-version: Two
+// rustfmt-error_on_line_overflow: false
+// rustfmt-indent_style: Block
+
+// rustfmt should not add trailing comma when rewriting macro. See #1528.
+fn a() {
+ panic!(
+ "this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:"
+ );
+ foo(
+ a,
+ oooptoptoptoptptooptoptoptoptptooptoptoptoptptoptoptoptoptpt(),
+ );
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_where_pred.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_where_pred.rs
new file mode 100644
index 000000000..ad7e0b8f3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_where_pred.rs
@@ -0,0 +1,12 @@
+// rustfmt-indent_style: Block
+// Where predicate indent
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+where
+ Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq,
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/default.rs b/src/tools/rustfmt/tests/target/configs/indent_style/default.rs
new file mode 100644
index 000000000..a8f0902b3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/default.rs
@@ -0,0 +1,11 @@
+// rustfmt-indent_style: Visual
+// Where style
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+ where Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/rfc_control.rs b/src/tools/rustfmt/tests/target/configs/indent_style/rfc_control.rs
new file mode 100644
index 000000000..6619d8b26
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/rfc_control.rs
@@ -0,0 +1,39 @@
+// rustfmt-indent_style: Block
+
+// #1618
+fn main() {
+ loop {
+ if foo {
+ if ((right_paddle_speed < 0.) && (right_paddle.position().y - paddle_size.y / 2. > 5.))
+ || ((right_paddle_speed > 0.)
+ && (right_paddle.position().y + paddle_size.y / 2. < game_height as f32 - 5.))
+ {
+ foo
+ }
+ if ai_timer.elapsed_time().as_microseconds() > ai_time.as_microseconds() {
+ if ball.position().y + ball_radius > right_paddle.position().y + paddle_size.y / 2.
+ {
+ foo
+ }
+ }
+ }
+ }
+}
+
+fn issue1656() {
+ {
+ {
+ match rewrite {
+ Some(ref body_str)
+ if (!body_str.contains('\n') && body_str.len() <= arm_shape.width)
+ || !context.config.match_arm_blocks()
+ || (extend && first_line_width(body_str) <= arm_shape.width)
+ || is_block =>
+ {
+ return None;
+ }
+ _ => {}
+ }
+ }
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/rfc_where.rs b/src/tools/rustfmt/tests/target/configs/indent_style/rfc_where.rs
new file mode 100644
index 000000000..a7b9a4f02
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/rfc_where.rs
@@ -0,0 +1,12 @@
+// rustfmt-indent_style: Block
+// Where style
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+where
+ Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq,
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_args.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_args.rs
new file mode 100644
index 000000000..04c2eaee3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_args.rs
@@ -0,0 +1,40 @@
+// rustfmt-indent_style: Visual
+// Function arguments layout
+
+fn lorem() {}
+
+fn lorem(ipsum: usize) {}
+
+fn lorem(ipsum: usize,
+ dolor: usize,
+ sit: usize,
+ amet: usize,
+ consectetur: usize,
+ adipiscing: usize,
+ elit: usize) {
+ // body
+}
+
+// #1922
+extern "C" {
+ pub fn LAPACKE_csytrs_rook_work(matrix_layout: c_int,
+ uplo: c_char,
+ n: lapack_int,
+ nrhs: lapack_int,
+ a: *const lapack_complex_float,
+ lda: lapack_int,
+ ipiv: *const lapack_int,
+ b: *mut lapack_complex_float,
+ ldb: lapack_int)
+ -> lapack_int;
+
+ pub fn LAPACKE_csytrs_rook_work(matrix_layout: c_int,
+ uplo: c_char,
+ n: lapack_int,
+ nrhs: lapack_int,
+ lda: lapack_int,
+ ipiv: *const lapack_int,
+ b: *mut lapack_complex_float,
+ ldb: lapack_int)
+ -> lapack_int;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_array.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_array.rs
new file mode 100644
index 000000000..1da6ff237
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_array.rs
@@ -0,0 +1,12 @@
+// rustfmt-indent_style: Visual
+// Array layout
+
+fn main() {
+ let lorem = vec!["ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit"];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_call.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_call.rs
new file mode 100644
index 000000000..5454c44ef
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_call.rs
@@ -0,0 +1,13 @@
+// rustfmt-indent_style: Visual
+// Function call style
+
+fn main() {
+ lorem("lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit");
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_chain.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_chain.rs
new file mode 100644
index 000000000..569f3d8b8
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_chain.rs
@@ -0,0 +1,11 @@
+// rustfmt-indent_style: Visual
+// Chain indent
+
+fn main() {
+ let lorem = ipsum.dolor()
+ .sit()
+ .amet()
+ .consectetur()
+ .adipiscing()
+ .elite();
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_generics.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_generics.rs
new file mode 100644
index 000000000..491075a14
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_generics.rs
@@ -0,0 +1,20 @@
+// rustfmt-indent_style: Visual
+// Generics indent
+
+fn lorem<Ipsum: Eq = usize,
+ Dolor: Eq = usize,
+ Sit: Eq = usize,
+ Amet: Eq = usize,
+ Adipiscing: Eq = usize,
+ Consectetur: Eq = usize,
+ Elit: Eq = usize>(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ adipiscing: Adipiscing,
+ consectetur: Consectetur,
+ elit: Elit)
+ -> T {
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_struct_lit.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_struct_lit.rs
new file mode 100644
index 000000000..ec49021d3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_struct_lit.rs
@@ -0,0 +1,7 @@
+// rustfmt-indent_style: Visual
+// Struct literal-style
+
+fn main() {
+ let lorem = Lorem { ipsum: dolor,
+ sit: amet };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_trailing_comma.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_trailing_comma.rs
new file mode 100644
index 000000000..9738d397d
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_trailing_comma.rs
@@ -0,0 +1,7 @@
+// rustfmt-error_on_line_overflow: false
+// rustfmt-indent_style: Visual
+
+// rustfmt should not add trailing comma when rewriting macro. See #1528.
+fn a() {
+ panic!("this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:");
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_where_pred.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_where_pred.rs
new file mode 100644
index 000000000..45799dcd5
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_where_pred.rs
@@ -0,0 +1,11 @@
+// rustfmt-indent_style: Visual
+// Where predicate indent
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+ where Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/match_arm_blocks/false.rs b/src/tools/rustfmt/tests/target/configs/match_arm_blocks/false.rs
new file mode 100644
index 000000000..7a9834168
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/match_arm_blocks/false.rs
@@ -0,0 +1,12 @@
+// rustfmt-match_arm_blocks: false
+// Wrap match-arms
+
+fn main() {
+ match lorem {
+ true =>
+ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
+ false => {
+ println!("{}", sit)
+ }
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/match_arm_blocks/true.rs b/src/tools/rustfmt/tests/target/configs/match_arm_blocks/true.rs
new file mode 100644
index 000000000..eb9e34059
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/match_arm_blocks/true.rs
@@ -0,0 +1,13 @@
+// rustfmt-match_arm_blocks: true
+// Wrap match-arms
+
+fn main() {
+ match lorem {
+ true => {
+ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
+ }
+ false => {
+ println!("{}", sit)
+ }
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/always.rs b/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/always.rs
new file mode 100644
index 000000000..f2af81eac
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/always.rs
@@ -0,0 +1,27 @@
+// rustfmt-match_arm_leading_pipes: Always
+
+fn foo() {
+ match foo {
+ | "foo" | "bar" => {}
+ | "baz"
+ | "something relatively long"
+ | "something really really really realllllllllllllly long" => println!("x"),
+ | "qux" => println!("y"),
+ | _ => {}
+ }
+}
+
+fn issue_3973() {
+ match foo {
+ | "foo" | "bar" => {}
+ | _ => {}
+ }
+}
+
+fn bar() {
+ match baz {
+ | "qux" => {}
+ | "foo" | "bar" => {}
+ | _ => {}
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/never.rs b/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/never.rs
new file mode 100644
index 000000000..345014e4b
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/never.rs
@@ -0,0 +1,27 @@
+// rustfmt-match_arm_leading_pipes: Never
+
+fn foo() {
+ match foo {
+ "foo" | "bar" => {}
+ "baz"
+ | "something relatively long"
+ | "something really really really realllllllllllllly long" => println!("x"),
+ "qux" => println!("y"),
+ _ => {}
+ }
+}
+
+fn issue_3973() {
+ match foo {
+ "foo" | "bar" => {}
+ _ => {}
+ }
+}
+
+fn bar() {
+ match baz {
+ "qux" => {}
+ "foo" | "bar" => {}
+ _ => {}
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/preserve.rs b/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/preserve.rs
new file mode 100644
index 000000000..477557584
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/match_arm_leading_pipes/preserve.rs
@@ -0,0 +1,35 @@
+// rustfmt-match_arm_leading_pipes: Preserve
+
+fn foo() {
+ match foo {
+ | "foo" | "bar" => {}
+ | "baz"
+ | "something relatively long"
+ | "something really really really realllllllllllllly long" => println!("x"),
+ | "qux" => println!("y"),
+ _ => {}
+ }
+}
+
+fn issue_3973() {
+ match foo {
+ | "foo" | "bar" => {}
+ _ => {}
+ }
+}
+
+fn bar() {
+ match baz {
+ "qux" => {}
+ "foo" | "bar" => {}
+ _ => {}
+ }
+}
+
+fn f(x: NonAscii) -> bool {
+ match x {
+ // foo
+ | Éfgh => true,
+ _ => false,
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/match_block_trailing_comma/false.rs b/src/tools/rustfmt/tests/target/configs/match_block_trailing_comma/false.rs
new file mode 100644
index 000000000..70e02955f
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/match_block_trailing_comma/false.rs
@@ -0,0 +1,11 @@
+// rustfmt-match_block_trailing_comma: false
+// Match block trailing comma
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ println!("ipsum");
+ }
+ Lorem::Dolor => println!("dolor"),
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/match_block_trailing_comma/true.rs b/src/tools/rustfmt/tests/target/configs/match_block_trailing_comma/true.rs
new file mode 100644
index 000000000..b78b046dc
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/match_block_trailing_comma/true.rs
@@ -0,0 +1,11 @@
+// rustfmt-match_block_trailing_comma: true
+// Match block trailing comma
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ println!("ipsum");
+ },
+ Lorem::Dolor => println!("dolor"),
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/merge_derives/true.rs b/src/tools/rustfmt/tests/target/configs/merge_derives/true.rs
new file mode 100644
index 000000000..4d0148b1c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/merge_derives/true.rs
@@ -0,0 +1,40 @@
+// rustfmt-merge_derives: true
+// Merge multiple derives to a single one.
+
+#[bar]
+#[derive(Eq, PartialEq)]
+#[foo]
+#[derive(Debug)]
+#[foobar]
+#[derive(Copy, Clone)]
+pub enum Foo {}
+
+#[derive(Eq, PartialEq, Debug)]
+#[foobar]
+#[derive(Copy, Clone)]
+pub enum Bar {}
+
+#[derive(Eq, PartialEq, Debug, Copy, Clone)]
+pub enum FooBar {}
+
+mod foo {
+ #[bar]
+ #[derive(Eq, PartialEq)]
+ #[foo]
+ #[derive(Debug)]
+ #[foobar]
+ #[derive(Copy, Clone)]
+ pub enum Foo {}
+}
+
+mod bar {
+ #[derive(Eq, PartialEq, Debug)]
+ #[foobar]
+ #[derive(Copy, Clone)]
+ pub enum Bar {}
+}
+
+mod foobar {
+ #[derive(Eq, PartialEq, Debug, Copy, Clone)]
+ pub enum FooBar {}
+}
diff --git a/src/tools/rustfmt/tests/target/configs/normalize_comments/false.rs b/src/tools/rustfmt/tests/target/configs/normalize_comments/false.rs
new file mode 100644
index 000000000..488962ed9
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/normalize_comments/false.rs
@@ -0,0 +1,13 @@
+// rustfmt-normalize_comments: false
+// Normalize comments
+
+// Lorem ipsum:
+fn dolor() -> usize {}
+
+/* sit amet: */
+fn adipiscing() -> usize {}
+
+// #652
+////////////////////////////////////////////////////////////////////////////////
+// Basic slice extension methods
+////////////////////////////////////////////////////////////////////////////////
diff --git a/src/tools/rustfmt/tests/target/configs/normalize_comments/true.rs b/src/tools/rustfmt/tests/target/configs/normalize_comments/true.rs
new file mode 100644
index 000000000..0bdbe08ab
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/normalize_comments/true.rs
@@ -0,0 +1,13 @@
+// rustfmt-normalize_comments: true
+// Normalize comments
+
+// Lorem ipsum:
+fn dolor() -> usize {}
+
+// sit amet:
+fn adipiscing() -> usize {}
+
+// #652
+////////////////////////////////////////////////////////////////////////////////
+// Basic slice extension methods
+////////////////////////////////////////////////////////////////////////////////
diff --git a/src/tools/rustfmt/tests/target/configs/normalize_doc_attributes/false.rs b/src/tools/rustfmt/tests/target/configs/normalize_doc_attributes/false.rs
new file mode 100644
index 000000000..f8eb64273
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/normalize_doc_attributes/false.rs
@@ -0,0 +1,13 @@
+// rustfmt-normalize_doc_attributes: false
+// Normalize doc attributes
+
+#![doc = " Example documentation"]
+
+#[doc = " Example item documentation"]
+pub enum Foo {}
+
+#[doc = " Lots of space"]
+pub enum Bar {}
+
+#[doc = "no leading space"]
+pub mod FooBar {}
diff --git a/src/tools/rustfmt/tests/target/configs/normalize_doc_attributes/true.rs b/src/tools/rustfmt/tests/target/configs/normalize_doc_attributes/true.rs
new file mode 100644
index 000000000..fadab985b
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/normalize_doc_attributes/true.rs
@@ -0,0 +1,13 @@
+// rustfmt-normalize_doc_attributes: true
+// Normalize doc attributes
+
+//! Example documentation
+
+/// Example item documentation
+pub enum Foo {}
+
+/// Lots of space
+pub enum Bar {}
+
+///no leading space
+pub mod FooBar {}
diff --git a/src/tools/rustfmt/tests/target/configs/remove_nested_parens/remove_nested_parens.rs b/src/tools/rustfmt/tests/target/configs/remove_nested_parens/remove_nested_parens.rs
new file mode 100644
index 000000000..d896042c3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/remove_nested_parens/remove_nested_parens.rs
@@ -0,0 +1,5 @@
+// rustfmt-remove_nested_parens: true
+
+fn main() {
+ (foo());
+}
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_impl_items/false.rs b/src/tools/rustfmt/tests/target/configs/reorder_impl_items/false.rs
new file mode 100644
index 000000000..beb99f0fb
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_impl_items/false.rs
@@ -0,0 +1,11 @@
+// rustfmt-reorder_impl_items: false
+
+struct Dummy;
+
+impl Iterator for Dummy {
+ fn next(&mut self) -> Option<Self::Item> {
+ None
+ }
+
+ type Item = i32;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_impl_items/true.rs b/src/tools/rustfmt/tests/target/configs/reorder_impl_items/true.rs
new file mode 100644
index 000000000..f2294412a
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_impl_items/true.rs
@@ -0,0 +1,11 @@
+// rustfmt-reorder_impl_items: true
+
+struct Dummy;
+
+impl Iterator for Dummy {
+ type Item = i32;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ None
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_imports/false.rs b/src/tools/rustfmt/tests/target/configs/reorder_imports/false.rs
new file mode 100644
index 000000000..4b85684dc
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_imports/false.rs
@@ -0,0 +1,7 @@
+// rustfmt-reorder_imports: false
+// Reorder imports
+
+use lorem;
+use ipsum;
+use dolor;
+use sit;
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_imports/true.rs b/src/tools/rustfmt/tests/target/configs/reorder_imports/true.rs
new file mode 100644
index 000000000..e4ff7295f
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_imports/true.rs
@@ -0,0 +1,19 @@
+// rustfmt-reorder_imports: true
+// Reorder imports
+
+use dolor;
+use ipsum;
+use lorem;
+use sit;
+
+fn foo() {
+ use A;
+ use B;
+ use C;
+
+ bar();
+
+ use D;
+ use E;
+ use F;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_modules/dolor/mod.rs b/src/tools/rustfmt/tests/target/configs/reorder_modules/dolor/mod.rs
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_modules/dolor/mod.rs
@@ -0,0 +1 @@
+
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_modules/false.rs b/src/tools/rustfmt/tests/target/configs/reorder_modules/false.rs
new file mode 100644
index 000000000..56b1aa03e
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_modules/false.rs
@@ -0,0 +1,7 @@
+// rustfmt-reorder_modules: false
+// Reorder modules
+
+mod lorem;
+mod ipsum;
+mod dolor;
+mod sit;
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_modules/ipsum/mod.rs b/src/tools/rustfmt/tests/target/configs/reorder_modules/ipsum/mod.rs
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_modules/ipsum/mod.rs
@@ -0,0 +1 @@
+
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_modules/lorem/mod.rs b/src/tools/rustfmt/tests/target/configs/reorder_modules/lorem/mod.rs
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_modules/lorem/mod.rs
@@ -0,0 +1 @@
+
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_modules/sit/mod.rs b/src/tools/rustfmt/tests/target/configs/reorder_modules/sit/mod.rs
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_modules/sit/mod.rs
@@ -0,0 +1 @@
+
diff --git a/src/tools/rustfmt/tests/target/configs/reorder_modules/true.rs b/src/tools/rustfmt/tests/target/configs/reorder_modules/true.rs
new file mode 100644
index 000000000..18361e88b
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/reorder_modules/true.rs
@@ -0,0 +1,7 @@
+// rustfmt-reorder_modules: true
+// Reorder modules
+
+mod dolor;
+mod ipsum;
+mod lorem;
+mod sit;
diff --git a/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/10.rs b/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/10.rs
new file mode 100644
index 000000000..78c4adba1
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/10.rs
@@ -0,0 +1,11 @@
+// rustfmt-short_array_element_width_threshold: 10
+
+fn main() {
+ pub const FORMAT_TEST: [u64; 5] = [
+ 0x0000000000000000,
+ 0xaaaaaaaaaaaaaaaa,
+ 0xbbbbbbbbbbbbbbbb,
+ 0xcccccccccccccccc,
+ 0xdddddddddddddddd,
+ ];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/20.rs b/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/20.rs
new file mode 100644
index 000000000..608469065
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/20.rs
@@ -0,0 +1,8 @@
+// rustfmt-short_array_element_width_threshold: 20
+
+fn main() {
+ pub const FORMAT_TEST: [u64; 5] = [
+ 0x0000000000000000, 0xaaaaaaaaaaaaaaaa, 0xbbbbbbbbbbbbbbbb, 0xcccccccccccccccc,
+ 0xdddddddddddddddd,
+ ];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/greater_than_max_width.rs b/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/greater_than_max_width.rs
new file mode 100644
index 000000000..710b6fe7c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/short_array_element_width_threshold/greater_than_max_width.rs
@@ -0,0 +1,12 @@
+// rustfmt-max_width: 20
+// rustfmt-short_array_element_width_threshold: 30
+
+fn main() {
+ pub const FORMAT_TEST: [u64; 5] = [
+ 0x0000000000000000,
+ 0xaaaaaaaaaaaaaaaa,
+ 0xbbbbbbbbbbbbbbbb,
+ 0xcccccccccccccccc,
+ 0xdddddddddddddddd,
+ ];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/skip_children/foo/mod.rs b/src/tools/rustfmt/tests/target/configs/skip_children/foo/mod.rs
new file mode 100644
index 000000000..d7ff6cdb8
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/skip_children/foo/mod.rs
@@ -0,0 +1,3 @@
+fn skip_formatting_this() {
+ println ! ( "Skip this" ) ;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/skip_children/true.rs b/src/tools/rustfmt/tests/target/configs/skip_children/true.rs
new file mode 100644
index 000000000..33fd782b4
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/skip_children/true.rs
@@ -0,0 +1,4 @@
+// rustfmt-skip_children: true
+
+mod foo;
+mod void;
diff --git a/src/tools/rustfmt/tests/target/configs/space_before_colon/true.rs b/src/tools/rustfmt/tests/target/configs/space_before_colon/true.rs
new file mode 100644
index 000000000..e2895b5d7
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/space_before_colon/true.rs
@@ -0,0 +1,11 @@
+// rustfmt-space_before_colon: true
+// Space before colon
+
+fn lorem<T : Eq>(t : T) {
+ let ipsum : Dolor = sit;
+}
+
+const LOREM : Lorem = Lorem {
+ ipsum : dolor,
+ sit : amet,
+};
diff --git a/src/tools/rustfmt/tests/target/configs/spaces_around_ranges/false.rs b/src/tools/rustfmt/tests/target/configs/spaces_around_ranges/false.rs
new file mode 100644
index 000000000..72b1be480
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/spaces_around_ranges/false.rs
@@ -0,0 +1,34 @@
+// rustfmt-spaces_around_ranges: false
+// Spaces around ranges
+
+fn main() {
+ let lorem = 0..10;
+ let ipsum = 0..=10;
+
+ match lorem {
+ 1..5 => foo(),
+ _ => bar,
+ }
+
+ match lorem {
+ 1..=5 => foo(),
+ _ => bar,
+ }
+
+ match lorem {
+ 1...5 => foo(),
+ _ => bar,
+ }
+}
+
+fn half_open() {
+ match [5..4, 99..105, 43..44] {
+ [_, 99.., _] => {}
+ [_, ..105, _] => {}
+ _ => {}
+ };
+
+ if let ..=5 = 0 {}
+ if let ..5 = 0 {}
+ if let 5.. = 0 {}
+}
diff --git a/src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs b/src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs
new file mode 100644
index 000000000..c56fdbb02
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs
@@ -0,0 +1,34 @@
+// rustfmt-spaces_around_ranges: true
+// Spaces around ranges
+
+fn main() {
+ let lorem = 0 .. 10;
+ let ipsum = 0 ..= 10;
+
+ match lorem {
+ 1 .. 5 => foo(),
+ _ => bar,
+ }
+
+ match lorem {
+ 1 ..= 5 => foo(),
+ _ => bar,
+ }
+
+ match lorem {
+ 1 ... 5 => foo(),
+ _ => bar,
+ }
+}
+
+fn half_open() {
+ match [5 .. 4, 99 .. 105, 43 .. 44] {
+ [_, 99 .., _] => {}
+ [_, .. 105, _] => {}
+ _ => {}
+ };
+
+ if let ..= 5 = 0 {}
+ if let .. 5 = 0 {}
+ if let 5 .. = 0 {}
+}
diff --git a/src/tools/rustfmt/tests/target/configs/struct_field_align_threshold/20.rs b/src/tools/rustfmt/tests/target/configs/struct_field_align_threshold/20.rs
new file mode 100644
index 000000000..12a523e9d
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/struct_field_align_threshold/20.rs
@@ -0,0 +1,471 @@
+// rustfmt-struct_field_align_threshold: 20
+// rustfmt-normalize_comments: true
+// rustfmt-wrap_comments: true
+// rustfmt-error_on_line_overflow: false
+
+struct Foo {
+ x: u32,
+ yy: u32, // comment
+ zzz: u32,
+}
+
+pub struct Bar {
+ x: u32,
+ yy: u32,
+ zzz: u32,
+
+ xxxxxxx: u32,
+}
+
+fn main() {
+ let foo = Foo {
+ x: 0,
+ yy: 1,
+ zzz: 2,
+ };
+
+ let bar = Bar {
+ x: 0,
+ yy: 1,
+ zzz: 2,
+
+ xxxxxxx: 3,
+ };
+}
+
+/// A Doc comment
+#[AnAttribute]
+pub struct Foo {
+ #[rustfmt::skip]
+ f : SomeType, // Comment beside a field
+ f: SomeType, // Comment beside a field
+ // Comment on a field
+ #[AnAttribute]
+ g: SomeOtherType,
+ /// A doc comment on a field
+ h: AThirdType,
+ pub i: TypeForPublicField,
+}
+
+// #1029
+pub struct Foo {
+ #[doc(hidden)]
+ // This will NOT get deleted!
+ bar: String, // hi
+}
+
+// #1029
+struct X {
+ // `x` is an important number.
+ #[allow(unused)] // TODO: use
+ x: u32,
+}
+
+// #410
+#[allow(missing_docs)]
+pub struct Writebatch<K: Key> {
+ #[allow(dead_code)] // only used for holding the internal pointer
+ writebatch: RawWritebatch,
+ marker: PhantomData<K>,
+}
+
+struct Bar;
+
+struct NewType(Type, OtherType);
+
+struct NewInt<T: Copy>(
+ pub i32,
+ SomeType, // inline comment
+ T, // sup
+);
+
+struct Qux<
+ 'a,
+ N: Clone + 'a,
+ E: Clone + 'a,
+ G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
+ W: Write + Copy,
+>(
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
+ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
+ #[AnAttr]
+ // Comment
+ /// Testdoc
+ G,
+ pub W,
+);
+
+struct Tuple(
+ // Comment 1
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+ // Comment 2
+ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
+);
+
+// With a where-clause and generics.
+pub struct Foo<'a, Y: Baz>
+where
+ X: Whatever,
+{
+ f: SomeType, // Comment beside a field
+}
+
+struct Baz {
+ a: A, // Comment A
+ b: B, // Comment B
+ c: C, // Comment C
+}
+
+struct Baz {
+ a: A, // Comment A
+
+ b: B, // Comment B
+
+ c: C, // Comment C
+}
+
+struct Baz {
+ a: A,
+
+ b: B,
+ c: C,
+
+ d: D,
+}
+
+struct Baz {
+ // Comment A
+ a: A,
+
+ // Comment B
+ b: B,
+ // Comment C
+ c: C,
+}
+
+// Will this be a one-liner?
+struct Tuple(
+ A, // Comment
+ B,
+);
+
+pub struct State<F: FnMut() -> time::Timespec> {
+ now: F,
+}
+
+pub struct State<F: FnMut() -> ()> {
+ now: F,
+}
+
+pub struct State<F: FnMut()> {
+ now: F,
+}
+
+struct Palette {
+ /// A map of indices in the palette to a count of pixels in approximately
+ /// that color
+ foo: i32,
+}
+
+// Splitting a single line comment into a block previously had a misalignment
+// when the field had attributes
+struct FieldsWithAttributes {
+ // Pre Comment
+ #[rustfmt::skip] pub host:String, /* Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB
+ * BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
+ // Another pre comment
+ #[attr1]
+ #[attr2]
+ pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
+ * CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
+}
+
+struct Deep {
+ deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
+ node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>,
+}
+
+struct Foo<T>(T);
+struct Foo<T>(T)
+where
+ T: Copy,
+ T: Eq;
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUUUUUUU,
+ TTTTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUU,
+);
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUUUUUUU,
+ TTTTTTTTTTTTTTTTTTT,
+)
+where
+ T: PartialEq;
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUUUUUUU,
+ TTTTTTTTTTTTTTTTTTTTT,
+)
+where
+ T: PartialEq;
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUUUUUUU,
+ TTTTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUU,
+)
+where
+ T: PartialEq;
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTT, // Foo
+ UUUUUUUUUUUUUUUUUUUUUUUU, // Bar
+ // Baz
+ TTTTTTTTTTTTTTTTTTT,
+ // Qux (FIXME #572 - doc comment)
+ UUUUUUUUUUUUUUUUUUU,
+);
+
+mod m {
+ struct X<T>
+ where
+ T: Sized,
+ {
+ a: T,
+ }
+}
+
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTTTT,
+ /// Qux
+ UUUUUUUUUUUUUUUUUUU,
+);
+
+struct Issue677 {
+ pub ptr: *const libc::c_void,
+ pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
+}
+
+struct Foo {}
+struct Foo {}
+struct Foo {
+ // comment
+}
+struct Foo {
+ // trailing space ->
+}
+struct Foo {
+ // comment
+}
+struct Foo(
+ // comment
+);
+
+struct LongStruct {
+ a: A,
+ the_quick_brown_fox_jumps_over_the_lazy_dog:
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+}
+
+struct Deep {
+ deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
+ node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
+}
+
+struct Foo<C = ()>(String);
+
+// #1364
+fn foo() {
+ convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
+ convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
+ convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
+ convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
+}
+
+fn main() {
+ let x = Bar;
+
+ // Comment
+ let y = Foo { a: x };
+
+ Foo {
+ a: foo(), // comment
+ // comment
+ b: bar(),
+ ..something
+ };
+
+ Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b() };
+
+ Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
+ a: f(),
+ b: b(),
+ };
+
+ Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
+ // Comment
+ a: foo(), // Comment
+ // Comment
+ b: bar(), // Comment
+ };
+
+ Foo { a: Bar, b: f() };
+
+ Quux {
+ x: if cond {
+ bar();
+ },
+ y: baz(),
+ };
+
+ A {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit
+ // amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante
+ // hendrerit. Donec et mollis dolor.
+ first: item(),
+ // Praesent et diam eget libero egestas mattis sit amet vitae augue.
+ // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
+ second: Item,
+ };
+
+ Some(Data::MethodCallData(MethodCallData {
+ span: sub_span.unwrap(),
+ scope: self.enclosing_scope(id),
+ ref_id: def_id,
+ decl_id: Some(decl_id),
+ }));
+
+ Diagram {
+ // o This graph demonstrates how
+ // / \ significant whitespace is
+ // o o preserved.
+ // /|\ \
+ // o o o o
+ graph: G,
+ }
+}
+
+fn matcher() {
+ TagTerminatedByteMatcher {
+ matcher: ByteMatcher {
+ pattern: b"<HTML",
+ mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
+ },
+ };
+}
+
+fn issue177() {
+ struct Foo<T> {
+ memb: T,
+ }
+ let foo = Foo::<i64> { memb: 10 };
+}
+
+fn issue201() {
+ let s = S { a: 0, ..b };
+}
+
+fn issue201_2() {
+ let s = S { a: S2 { ..c }, ..b };
+}
+
+fn issue278() {
+ let s = S {
+ a: 0,
+ //
+ b: 0,
+ };
+ let s1 = S {
+ a: 0,
+ // foo
+ //
+ // bar
+ b: 0,
+ };
+}
+
+fn struct_exprs() {
+ Foo { a: 1, b: f(2) };
+ Foo {
+ a: 1,
+ b: f(2),
+ ..g(3)
+ };
+ LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct {
+ ..base
+ };
+ IntrinsicISizesContribution {
+ content_intrinsic_sizes: IntrinsicISizes {
+ minimum_inline_size: 0,
+ },
+ };
+}
+
+fn issue123() {
+ Foo { a: b, c: d, e: f };
+
+ Foo {
+ a: bb,
+ c: dd,
+ e: ff,
+ };
+
+ Foo {
+ a: ddddddddddddddddddddd,
+ b: cccccccccccccccccccccccccccccccccccccc,
+ };
+}
+
+fn issue491() {
+ Foo {
+ guard: None,
+ arm: 0, // Comment
+ };
+
+ Foo {
+ arm: 0, // Comment
+ };
+
+ Foo {
+ a: aaaaaaaaaa,
+ b: bbbbbbbb,
+ c: cccccccccc,
+ d: dddddddddd, // a comment
+ e: eeeeeeeee,
+ };
+}
+
+fn issue698() {
+ Record {
+ ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ };
+ Record {
+ ffffffffffffffffffffffffffields:
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ }
+}
+
+fn issue835() {
+ MyStruct {};
+ MyStruct { /* a comment */ };
+ MyStruct {
+ // Another comment
+ };
+ MyStruct {}
+}
+
+fn field_init_shorthand() {
+ MyStruct { x, y, z };
+ MyStruct { x, y, z, ..base };
+ Foo {
+ aaaaaaaaaa,
+ bbbbbbbb,
+ cccccccccc,
+ dddddddddd, // a comment
+ eeeeeeeee,
+ };
+ Record {
+ ffffffffffffffffffffffffffieldsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/struct_lit_single_line/false.rs b/src/tools/rustfmt/tests/target/configs/struct_lit_single_line/false.rs
new file mode 100644
index 000000000..e2732b5a7
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/struct_lit_single_line/false.rs
@@ -0,0 +1,9 @@
+// rustfmt-struct_lit_single_line: false
+// Struct literal multiline-style
+
+fn main() {
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/tab_spaces/2.rs b/src/tools/rustfmt/tests/target/configs/tab_spaces/2.rs
new file mode 100644
index 000000000..85961706e
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/tab_spaces/2.rs
@@ -0,0 +1,14 @@
+// rustfmt-tab_spaces: 2
+// rustfmt-max_width: 30
+// rustfmt-indent_style: Block
+// Tab spaces
+
+fn lorem() {
+ let ipsum = dolor();
+ let sit = vec![
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit.",
+ ];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/tab_spaces/4.rs b/src/tools/rustfmt/tests/target/configs/tab_spaces/4.rs
new file mode 100644
index 000000000..524a55121
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/tab_spaces/4.rs
@@ -0,0 +1,14 @@
+// rustfmt-tab_spaces: 4
+// rustfmt-max_width: 30
+// rustfmt-indent_style: Block
+// Tab spaces
+
+fn lorem() {
+ let ipsum = dolor();
+ let sit = vec![
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit.",
+ ];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/trailing_comma/always.rs b/src/tools/rustfmt/tests/target/configs/trailing_comma/always.rs
new file mode 100644
index 000000000..951dc6809
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/trailing_comma/always.rs
@@ -0,0 +1,14 @@
+// rustfmt-trailing_comma: Always
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit, } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing,
+ } = elit;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/trailing_comma/never.rs b/src/tools/rustfmt/tests/target/configs/trailing_comma/never.rs
new file mode 100644
index 000000000..ae0e50f96
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/trailing_comma/never.rs
@@ -0,0 +1,35 @@
+// rustfmt-trailing_comma: Never
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing
+ } = elit;
+
+ // #1544
+ if let VrMsg::ClientReply {
+ request_num: reply_req_num,
+ value,
+ ..
+ } = msg
+ {
+ let _ = safe_assert_eq!(reply_req_num, request_num, op);
+ return Ok((request_num, op, value));
+ }
+
+ // #1710
+ pub struct FileInput {
+ input: StringInput,
+ file_name: OsString
+ }
+ match len {
+ Some(len) => Ok(new(self.input, self.pos + len)),
+ None => Err(self)
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/trailing_comma/vertical.rs b/src/tools/rustfmt/tests/target/configs/trailing_comma/vertical.rs
new file mode 100644
index 000000000..7283cde8d
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/trailing_comma/vertical.rs
@@ -0,0 +1,14 @@
+// rustfmt-trailing_comma: Vertical
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing,
+ } = elit;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/trailing_semicolon/false.rs b/src/tools/rustfmt/tests/target/configs/trailing_semicolon/false.rs
new file mode 100644
index 000000000..9fa746e9c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/trailing_semicolon/false.rs
@@ -0,0 +1,27 @@
+// rustfmt-trailing_semicolon: false
+
+#![feature(loop_break_value)]
+
+fn main() {
+ 'a: loop {
+ break 'a
+ }
+
+ let mut done = false;
+ 'b: while !done {
+ done = true;
+ continue 'b
+ }
+
+ let x = loop {
+ break 5
+ };
+
+ let x = 'c: loop {
+ break 'c 5
+ };
+}
+
+fn foo() -> usize {
+ return 0
+}
diff --git a/src/tools/rustfmt/tests/target/configs/trailing_semicolon/true.rs b/src/tools/rustfmt/tests/target/configs/trailing_semicolon/true.rs
new file mode 100644
index 000000000..61b6843d6
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/trailing_semicolon/true.rs
@@ -0,0 +1,27 @@
+// rustfmt-trailing_semicolon: true
+
+#![feature(loop_break_value)]
+
+fn main() {
+ 'a: loop {
+ break 'a;
+ }
+
+ let mut done = false;
+ 'b: while !done {
+ done = true;
+ continue 'b;
+ }
+
+ let x = loop {
+ break 5;
+ };
+
+ let x = 'c: loop {
+ break 'c 5;
+ };
+}
+
+fn foo() -> usize {
+ return 0;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/type_punctuation_density/compressed.rs b/src/tools/rustfmt/tests/target/configs/type_punctuation_density/compressed.rs
new file mode 100644
index 000000000..6571e448e
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/type_punctuation_density/compressed.rs
@@ -0,0 +1,41 @@
+// rustfmt-type_punctuation_density: Compressed
+// Type punctuation density
+
+fn lorem<Ipsum: Dolor+Sit=Amet>() {
+ // body
+}
+
+struct Foo<T: Eq+Clone, U>
+where
+ U: Eq+Clone, {
+ // body
+}
+
+trait Foo<'a, T=usize>
+where
+ T: 'a+Eq+Clone,
+{
+ type Bar: Eq+Clone;
+}
+
+trait Foo: Eq+Clone {
+ // body
+}
+
+impl<T> Foo<'a> for Bar
+where
+ for<'a> T: 'a+Eq+Clone,
+{
+ // body
+}
+
+fn foo<'a, 'b, 'c>()
+where
+ 'a: 'b+'c,
+{
+ // body
+}
+
+fn Foo<T=Foo, Output=Expr<'tcx>+Foo>() {
+ let i = 6;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/type_punctuation_density/wide.rs b/src/tools/rustfmt/tests/target/configs/type_punctuation_density/wide.rs
new file mode 100644
index 000000000..01546c7b0
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/type_punctuation_density/wide.rs
@@ -0,0 +1,41 @@
+// rustfmt-type_punctuation_density: Wide
+// Type punctuation density
+
+fn lorem<Ipsum: Dolor + Sit = Amet>() {
+ // body
+}
+
+struct Foo<T: Eq + Clone, U>
+where
+ U: Eq + Clone, {
+ // body
+}
+
+trait Foo<'a, T = usize>
+where
+ T: 'a + Eq + Clone,
+{
+ type Bar: Eq + Clone;
+}
+
+trait Foo: Eq + Clone {
+ // body
+}
+
+impl<T> Foo<'a> for Bar
+where
+ for<'a> T: 'a + Eq + Clone,
+{
+ // body
+}
+
+fn foo<'a, 'b, 'c>()
+where
+ 'a: 'b + 'c,
+{
+ // body
+}
+
+fn Foo<T = Foo, Output = Expr<'tcx> + Foo>() {
+ let i = 6;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/use_field_init_shorthand/false.rs b/src/tools/rustfmt/tests/target/configs/use_field_init_shorthand/false.rs
new file mode 100644
index 000000000..743304468
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/use_field_init_shorthand/false.rs
@@ -0,0 +1,15 @@
+// rustfmt-use_field_init_shorthand: false
+// Use field initialization shorthand if possible.
+
+fn main() {
+ let a = Foo { x: x, y: y, z: z };
+
+ let b = Bar {
+ x: x,
+ y: y,
+ #[attr]
+ z: z,
+ #[rustfmt::skip]
+ skipped: skipped,
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/use_field_init_shorthand/true.rs b/src/tools/rustfmt/tests/target/configs/use_field_init_shorthand/true.rs
new file mode 100644
index 000000000..8b80e8153
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/use_field_init_shorthand/true.rs
@@ -0,0 +1,15 @@
+// rustfmt-use_field_init_shorthand: true
+// Use field initialization shorthand if possible.
+
+fn main() {
+ let a = Foo { x, y, z };
+
+ let b = Bar {
+ x,
+ y,
+ #[attr]
+ z,
+ #[rustfmt::skip]
+ skipped: skipped,
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/use_small_heuristics/default.rs b/src/tools/rustfmt/tests/target/configs/use_small_heuristics/default.rs
new file mode 100644
index 000000000..d67bd9aaf
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/use_small_heuristics/default.rs
@@ -0,0 +1,26 @@
+// rustfmt-use_small_heuristics: Default
+
+enum Lorem {
+ Ipsum,
+ Dolor(bool),
+ Sit { amet: Consectetur, adipiscing: Elit },
+}
+
+fn main() {
+ lorem(
+ "lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ );
+
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+
+ let lorem = if ipsum { dolor } else { sit };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/use_small_heuristics/max.rs b/src/tools/rustfmt/tests/target/configs/use_small_heuristics/max.rs
new file mode 100644
index 000000000..785dfbea0
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/use_small_heuristics/max.rs
@@ -0,0 +1,15 @@
+// rustfmt-use_small_heuristics: Max
+
+enum Lorem {
+ Ipsum,
+ Dolor(bool),
+ Sit { amet: Consectetur, adipiscing: Elit },
+}
+
+fn main() {
+ lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
+
+ let lorem = Lorem { ipsum: dolor, sit: amet };
+
+ let lorem = if ipsum { dolor } else { sit };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/use_small_heuristics/off.rs b/src/tools/rustfmt/tests/target/configs/use_small_heuristics/off.rs
new file mode 100644
index 000000000..f76392d24
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/use_small_heuristics/off.rs
@@ -0,0 +1,25 @@
+// rustfmt-use_small_heuristics: Off
+
+enum Lorem {
+ Ipsum,
+ Dolor(bool),
+ Sit {
+ amet: Consectetur,
+ adipiscing: Elit,
+ },
+}
+
+fn main() {
+ lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
+
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+
+ let lorem = if ipsum {
+ dolor
+ } else {
+ sit
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/use_try_shorthand/false.rs b/src/tools/rustfmt/tests/target/configs/use_try_shorthand/false.rs
new file mode 100644
index 000000000..de7f8b4a5
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/use_try_shorthand/false.rs
@@ -0,0 +1,6 @@
+// rustfmt-use_try_shorthand: false
+// Use try! shorthand
+
+fn main() {
+ let lorem = try!(ipsum.map(|dolor| dolor.sit()));
+}
diff --git a/src/tools/rustfmt/tests/target/configs/use_try_shorthand/true.rs b/src/tools/rustfmt/tests/target/configs/use_try_shorthand/true.rs
new file mode 100644
index 000000000..d3aa03579
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/use_try_shorthand/true.rs
@@ -0,0 +1,6 @@
+// rustfmt-use_try_shorthand: true
+// Use try! shorthand
+
+fn main() {
+ let lorem = ipsum.map(|dolor| dolor.sit())?;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/where_single_line/true-with-brace-style.rs b/src/tools/rustfmt/tests/target/configs/where_single_line/true-with-brace-style.rs
new file mode 100644
index 000000000..ec7f79b68
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/where_single_line/true-with-brace-style.rs
@@ -0,0 +1,22 @@
+// rustfmt-brace_style: SameLineWhere
+// rustfmt-where_single_line: true
+
+fn lorem_multi_line_clauseless<Ipsum, Dolor, Sit, Amet>(
+ a: Aaaaaaaaaaaaaaa,
+ b: Bbbbbbbbbbbbbbbb,
+ c: Ccccccccccccccccc,
+ d: Ddddddddddddddddddddddddd,
+ e: Eeeeeeeeeeeeeeeeeee,
+) -> T {
+ // body
+}
+
+fn lorem_multi_line_clauseless<Ipsum, Dolor, Sit, Amet>(
+ a: Aaaaaaaaaaaaaaa,
+ b: Bbbbbbbbbbbbbbbb,
+ c: Ccccccccccccccccc,
+ d: Ddddddddddddddddddddddddd,
+ e: Eeeeeeeeeeeeeeeeeee,
+) {
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/where_single_line/true.rs b/src/tools/rustfmt/tests/target/configs/where_single_line/true.rs
new file mode 100644
index 000000000..7f816459e
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/where_single_line/true.rs
@@ -0,0 +1,30 @@
+// rustfmt-where_single_line: true
+// Where style
+
+fn lorem_two_items<Ipsum, Dolor, Sit, Amet>() -> T
+where
+ Ipsum: Eq,
+ Lorem: Eq,
+{
+ // body
+}
+
+fn lorem_multi_line<Ipsum, Dolor, Sit, Amet>(
+ a: Aaaaaaaaaaaaaaa,
+ b: Bbbbbbbbbbbbbbbb,
+ c: Ccccccccccccccccc,
+ d: Ddddddddddddddddddddddddd,
+ e: Eeeeeeeeeeeeeeeeeee,
+) -> T
+where
+ Ipsum: Eq,
+{
+ // body
+}
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+where Ipsum: Eq {
+ // body
+}
+
+unsafe impl Sync for Foo where (): Send {}
diff --git a/src/tools/rustfmt/tests/target/configs/wrap_comments/false.rs b/src/tools/rustfmt/tests/target/configs/wrap_comments/false.rs
new file mode 100644
index 000000000..48ecd88ac
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/wrap_comments/false.rs
@@ -0,0 +1,8 @@
+// rustfmt-wrap_comments: false
+// rustfmt-max_width: 50
+// rustfmt-error_on_line_overflow: false
+// Wrap comments
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+}
diff --git a/src/tools/rustfmt/tests/target/configs/wrap_comments/true.rs b/src/tools/rustfmt/tests/target/configs/wrap_comments/true.rs
new file mode 100644
index 000000000..4096fd4d8
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/wrap_comments/true.rs
@@ -0,0 +1,20 @@
+// rustfmt-wrap_comments: true
+// rustfmt-max_width: 50
+// Wrap comments
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur
+ // adipiscing elit, sed do eiusmod tempor
+ // incididunt ut labore et dolore magna
+ // aliqua. Ut enim ad minim veniam, quis
+ // nostrud exercitation ullamco laboris nisi
+ // ut aliquip ex ea commodo consequat.
+}
+
+fn code_block() {
+ // ```rust
+ // let x = 3;
+ //
+ // println!("x = {}", x);
+ // ```
+}