diff options
| author | Yacin Tmimi <yacintmimi@gmail.com> | 2024-06-12 22:37:39 -0400 |
|---|---|---|
| committer | Yacin Tmimi <yacintmimi@gmail.com> | 2024-06-12 22:37:39 -0400 |
| commit | 76cd550c54e1db846dd9edab9b920efbcf6eb874 (patch) | |
| tree | 6f50f542f2652ff9fcbbc181af43e06559fd377a /tests | |
| parent | 783a411f671e1c9aa580b33b0288d9c16e094a22 (diff) | |
| parent | c97996fab61fc09432abcf64dbe3ce2d84f4d679 (diff) | |
| download | rust-76cd550c54e1db846dd9edab9b920efbcf6eb874.tar.gz rust-76cd550c54e1db846dd9edab9b920efbcf6eb874.zip | |
Merge remote-tracking branch 'upstream/master' into subtree-push-nightly-2024-06-13
Diffstat (limited to 'tests')
47 files changed, 602 insertions, 10 deletions
diff --git a/tests/config/issue-5801-v1.toml b/tests/config/issue-5801-v1.toml new file mode 100644 index 00000000000..8695df0099e --- /dev/null +++ b/tests/config/issue-5801-v1.toml @@ -0,0 +1,3 @@ +max_width = 120 +version = "One" +attr_fn_like_width = 120 \ No newline at end of file diff --git a/tests/config/issue-5801-v2.toml b/tests/config/issue-5801-v2.toml new file mode 100644 index 00000000000..948f4fb66bf --- /dev/null +++ b/tests/config/issue-5801-v2.toml @@ -0,0 +1,3 @@ +max_width = 120 +version = "Two" +attr_fn_like_width = 120 \ No newline at end of file diff --git a/tests/mod-resolver/skip-files-issue-5065/main.rs b/tests/mod-resolver/skip-files-issue-5065/main.rs index 3122e4f220f..f102bf9d181 100644 --- a/tests/mod-resolver/skip-files-issue-5065/main.rs +++ b/tests/mod-resolver/skip-files-issue-5065/main.rs @@ -6,4 +6,4 @@ mod one; fn main() {println!("Hello, world!"); } -// trailing commet +// trailing comment diff --git a/tests/rustfmt/main.rs b/tests/rustfmt/main.rs index e66fad1e7fa..58cf0e5e4db 100644 --- a/tests/rustfmt/main.rs +++ b/tests/rustfmt/main.rs @@ -176,7 +176,14 @@ fn rustfmt_emits_error_on_line_overflow_true() { #[test] #[allow(non_snake_case)] fn dont_emit_ICE() { - let files = ["tests/target/issue_5728.rs", "tests/target/issue_5729.rs", "tests/target/issue_6082.rs"]; + let files = [ + "tests/target/issue_5728.rs", + "tests/target/issue_5729.rs", + "tests/target/issue-5885.rs", + "tests/target/issue_6082.rs", + "tests/target/issue_6069.rs", + "tests/target/issue-6105.rs", + ]; for file in files { let args = [file]; @@ -184,3 +191,19 @@ fn dont_emit_ICE() { assert!(!stderr.contains("thread 'main' panicked")); } } + +#[test] +fn rustfmt_emits_error_when_control_brace_style_is_always_next_line() { + // See also https://github.com/rust-lang/rustfmt/issues/5912 + let args = [ + "--config=color=Never", + "--config", + "control_brace_style=AlwaysNextLine", + "--config", + "match_arm_blocks=false", + "tests/target/issue_5912.rs", + ]; + + let (_stdout, stderr) = rustfmt(&args); + assert!(!stderr.contains("error[internal]: left behind trailing whitespace")) +} diff --git a/tests/source/arrow_in_comments/arrow_in_single_comment.rs b/tests/source/arrow_in_comments/arrow_in_single_comment.rs new file mode 100644 index 00000000000..fb0576a4822 --- /dev/null +++ b/tests/source/arrow_in_comments/arrow_in_single_comment.rs @@ -0,0 +1,10 @@ +// rustfmt-version: Two +fn main() { + match a { + _ => + // comment with => + { + println!("A") + } + } +} diff --git a/tests/source/arrow_in_comments/multiple_arrows.rs b/tests/source/arrow_in_comments/multiple_arrows.rs new file mode 100644 index 00000000000..fc696b309f2 --- /dev/null +++ b/tests/source/arrow_in_comments/multiple_arrows.rs @@ -0,0 +1,14 @@ +// rustfmt-version: Two +fn main() { + match a { + _ => // comment with => + match b { + // one goes to => + one => { + println("1"); + } + // two goes to => + two => { println("2"); } + } + } +} diff --git a/tests/source/configs/format_generated_files/false_with_generated_marker_line_search_limit.rs b/tests/source/configs/format_generated_files/false_with_generated_marker_line_search_limit.rs new file mode 100644 index 00000000000..be03849fe10 --- /dev/null +++ b/tests/source/configs/format_generated_files/false_with_generated_marker_line_search_limit.rs @@ -0,0 +1,10 @@ +// rustfmt-format_generated_files: false +// rustfmt-generated_marker_line_search_limit: 15 + +fn main() +{ + println!("hello, world") + ; +} + +// @generated \ No newline at end of file diff --git a/tests/source/configs/format_generated_files/false_with_marker_out_scope_size.rs b/tests/source/configs/format_generated_files/false_with_marker_out_scope_size.rs new file mode 100644 index 00000000000..abb97e6259f --- /dev/null +++ b/tests/source/configs/format_generated_files/false_with_marker_out_scope_size.rs @@ -0,0 +1,10 @@ +// rustfmt-format_generated_files: false +// rustfmt-generated_marker_line_search_limit: 1 + +fn main() +{ + println!("hello, world") + ; +} + +// @generated \ No newline at end of file diff --git a/tests/source/configs/format_generated_files/false_with_zero_search_limit.rs b/tests/source/configs/format_generated_files/false_with_zero_search_limit.rs new file mode 100644 index 00000000000..f6978d0f355 --- /dev/null +++ b/tests/source/configs/format_generated_files/false_with_zero_search_limit.rs @@ -0,0 +1,9 @@ +// rustfmt-format_generated_files: false +// rustfmt-generated_marker_line_search_limit: 0 + +// @generated +fn main() { + println!("hello, world") + ; +} +// @generated diff --git a/tests/source/configs/format_generated_files/true_with_marker_in_scope_size.rs b/tests/source/configs/format_generated_files/true_with_marker_in_scope_size.rs new file mode 100644 index 00000000000..53cc116ec2b --- /dev/null +++ b/tests/source/configs/format_generated_files/true_with_marker_in_scope_size.rs @@ -0,0 +1,10 @@ +// rustfmt-format_generated_files: true +// rustfmt-generated_marker_line_search_limit: 20 + +fn main() +{ + println!("hello, world") + ; +} + +// @generated diff --git a/tests/source/configs/format_generated_files/true_with_marker_not_in_header.rs b/tests/source/configs/format_generated_files/true_with_marker_not_in_header.rs new file mode 100644 index 00000000000..8eff1a3b0ee --- /dev/null +++ b/tests/source/configs/format_generated_files/true_with_marker_not_in_header.rs @@ -0,0 +1,9 @@ +// rustfmt-format_generated_files: true + +fn main() +{ + println!("hello, world") + ; +} + +// @generated \ No newline at end of file diff --git a/tests/source/issue-3805.rs b/tests/source/issue-3805.rs new file mode 100644 index 00000000000..a0289b57974 --- /dev/null +++ b/tests/source/issue-3805.rs @@ -0,0 +1,65 @@ +// rustfmt-version: Two +// rustfmt-format_macro_matchers: true + +// From original issue example - Line length 101 +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr) => {{ +return; +}}; +} + +// Spaces between the `{` and `}` +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr) => { { +return; +} }; +} + +// Multi `{}` +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr) => {{{{ +return; +}}}}; +} + +// Multi `{}` with spaces +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr) => { { { { +return; +} } } }; +} + +// Line length 102 +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeiou:expr, $add:expr) => {{ +return; +}}; +} + +// Line length 103 +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeioua:expr, $add:expr) => {{ +return; +}}; +} + +// With extended macro body - Line length 101 +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr) => {{ +let VAR = "VALUE"; return VAR; +}}; +} + +// With extended macro body - Line length 102 +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeiou:expr, $add:expr) => {{ +let VAR = "VALUE"; return VAR; +}}; +} + +// With extended macro body - Line length 103 +macro_rules! test { +($aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeioua:expr, $add:expr) => {{ +let VAR = "VALUE"; return VAR; +}}; +} diff --git a/tests/source/issue-5801/attribute_unexpectedly_wraps_before_max_width.rs b/tests/source/issue-5801/attribute_unexpectedly_wraps_before_max_width.rs new file mode 100644 index 00000000000..59902c7bcce --- /dev/null +++ b/tests/source/issue-5801/attribute_unexpectedly_wraps_before_max_width.rs @@ -0,0 +1,8 @@ +// rustfmt-config: issue-5801-v1.toml + +pub enum Severity { + #[something(AAAAAAAAAAAAA, BBBBBBBBBBBBBB, CCCCCCCCCCCCCCCC, DDDDDDDDDDDDD, EEEEEEEEEEEE, FFFFFFFFFFF, GGGGGGGGGGG)] + AttrsWillWrap, + #[something_else(hhhhhhhhhhhhhhhh, iiiiiiiiiiiiiiii, jjjjjjjjjjjjjjj, kkkkkkkkkkkkk, llllllllllll, mmmmmmmmmmmmmm)] + AttrsWontWrap, +} diff --git a/tests/source/issue-5801/comment_unexpectedly_wraps_before_max_width.rs b/tests/source/issue-5801/comment_unexpectedly_wraps_before_max_width.rs new file mode 100644 index 00000000000..5847afd9560 --- /dev/null +++ b/tests/source/issue-5801/comment_unexpectedly_wraps_before_max_width.rs @@ -0,0 +1,17 @@ +// rustfmt-comment_width: 120 +// rustfmt-wrap_comments: true +// rustfmt-max_width: 120 +// rustfmt-version: One + +/// This function is 120 columns wide and is left alone. This comment is 120 columns wide and the formatter is also fine +fn my_super_cool_function_name(my_very_cool_argument_name: String, my_other_very_cool_argument_name: String) -> String { + unimplemented!() +} + +pub enum Severity { + /// In version one, the below line got wrapped prematurely as we subtracted 1 to account for `,`. See issue #5801. + /// But here, this comment is 120 columns wide and the formatter wants to split it up onto two separate lines still. + Error, + /// This comment is 119 columns wide and works perfectly. Lorem ipsum. lorem ipsum. lorem ipsum. lorem ipsum lorem. + Warning, +} diff --git a/tests/source/issue-5987/two.rs b/tests/source/issue-5987/two.rs new file mode 100644 index 00000000000..e20026b5565 --- /dev/null +++ b/tests/source/issue-5987/two.rs @@ -0,0 +1,13 @@ +// rustfmt-version: Two + +fn main() { + trace!( + "get some longer length in here yes yes {} {}", + "hello", + "world" + ); + debug!( + "get some longer length in here yes yes {} {}", + "hello", "world" + ); +} diff --git a/tests/source/issue-6059/repro.rs b/tests/source/issue-6059/repro.rs new file mode 100644 index 00000000000..1dc62cc8d26 --- /dev/null +++ b/tests/source/issue-6059/repro.rs @@ -0,0 +1,3 @@ +fn float_range_tests() { + self.coords.x -= rng.gen_range(-self.radius / 2. .. self.radius / 2.); +} diff --git a/tests/source/issue-6147/case_rustfmt_v1.rs b/tests/source/issue-6147/case_rustfmt_v1.rs new file mode 100644 index 00000000000..2ac2e0361c3 --- /dev/null +++ b/tests/source/issue-6147/case_rustfmt_v1.rs @@ -0,0 +1,20 @@ +// rustfmt-version: One + +pub fn main() { +let a = Some(12); +match a { +#![attr1] +#![attr2] +#![attr3] +_ => None, +} + +{ +match a { +#![attr1] +#![attr2] +#![attr3] +_ => None, +} +} +} diff --git a/tests/source/issue-6147/case_rustfmt_v2.rs b/tests/source/issue-6147/case_rustfmt_v2.rs new file mode 100644 index 00000000000..c1bf1ad4bf8 --- /dev/null +++ b/tests/source/issue-6147/case_rustfmt_v2.rs @@ -0,0 +1,20 @@ +// rustfmt-version: Two + +pub fn main() { +let a = Some(12); +match a { +#![attr1] +#![attr2] +#![attr3] +_ => None, +} + +{ +match a { +#![attr1] +#![attr2] +#![attr3] +_ => None, +} +} +} diff --git a/tests/source/issue_5912.rs b/tests/source/issue_5912.rs new file mode 100644 index 00000000000..2265fd2146c --- /dev/null +++ b/tests/source/issue_5912.rs @@ -0,0 +1,15 @@ +// rustfmt-match_arm_blocks: false +// rustfmt-control_brace_style: AlwaysNextLine + +fn foo() { + match 0 { + 0 => { + aaaaaaaaaaaaaaaaaaaaaaaa + + bbbbbbbbbbbbbbbbbbbbbbbbb + + bbbbbbbbbbbbbbbbbbbbbbbbb + + bbbbbbbbbbbbbbbbbbbbbbbbb + + bbbbbbbbbbbbbbbbbbbbbbbbb + } + _ => 2, + } +} diff --git a/tests/source/let_else.rs b/tests/source/let_else.rs index cb2859e805d..c589ab75cd3 100644 --- a/tests/source/let_else.rs +++ b/tests/source/let_else.rs @@ -117,8 +117,8 @@ fn unbreakable_initializer_expr_pre_formatting_length_through_initializer_expr_n // Break after the `=` and put the initializer expr on it's own line. // Because the initializer expr is multi-lined the else is placed on it's own line. // The initializer expr has a length of 91, which when indented on the next line - // The `(indent)init` line has a lengh of 99. This is the max length that the `init` can be - // before we start running into max_width issues. I suspect this is becuase the shape is + // The `(indent)init` line has a length of 99. This is the max length that the `init` can be + // before we start running into max_width issues. I suspect this is because the shape is // accounting for the `;` at the end of the `let-else` statement. let Some(x) = some_really_really_really_really_really_really_really_really_really_really_long_name______I else {return}; @@ -127,7 +127,7 @@ fn unbreakable_initializer_expr_pre_formatting_length_through_initializer_expr_n // Post Formatting: // Max length issues prevent us from formatting. // The initializer expr has a length of 92, which if it would be indented on the next line - // the `(indent)init` line has a lengh of 100 which == max_width of 100. + // the `(indent)init` line has a length of 100 which == max_width of 100. // One might expect formatting to succeed, but I suspect the reason we hit max_width issues is // because the Shape is accounting for the `;` at the end of the `let-else` statement. let Some(x) = some_really_really_really_really_really_really_really_really_really_really_really_long_nameJ else {return}; diff --git a/tests/source/no_arg_with_commnet.rs b/tests/source/no_arg_with_commnet.rs index ea4ee0f1eee..41c3c6bea48 100644 --- a/tests/source/no_arg_with_commnet.rs +++ b/tests/source/no_arg_with_commnet.rs @@ -1,2 +1,2 @@ -fn foo( /* cooment */ +fn foo( /* comment */ ) {} diff --git a/tests/target/arrow_in_comments/arrow_in_single_comment.rs b/tests/target/arrow_in_comments/arrow_in_single_comment.rs new file mode 100644 index 00000000000..deffdbeeaaf --- /dev/null +++ b/tests/target/arrow_in_comments/arrow_in_single_comment.rs @@ -0,0 +1,10 @@ +// rustfmt-version: Two +fn main() { + match a { + _ => + // comment with => + { + println!("A") + } + } +} diff --git a/tests/target/arrow_in_comments/multiple_arrows.rs b/tests/target/arrow_in_comments/multiple_arrows.rs new file mode 100644 index 00000000000..b0443411816 --- /dev/null +++ b/tests/target/arrow_in_comments/multiple_arrows.rs @@ -0,0 +1,19 @@ +// rustfmt-version: Two +fn main() { + match a { + _ => + // comment with => + { + match b { + // one goes to => + one => { + println("1"); + } + // two goes to => + two => { + println("2"); + } + } + } + } +} diff --git a/tests/target/configs/format_generated_files/false_with_generated_marker_line_search_limit.rs b/tests/target/configs/format_generated_files/false_with_generated_marker_line_search_limit.rs new file mode 100644 index 00000000000..be03849fe10 --- /dev/null +++ b/tests/target/configs/format_generated_files/false_with_generated_marker_line_search_limit.rs @@ -0,0 +1,10 @@ +// rustfmt-format_generated_files: false +// rustfmt-generated_marker_line_search_limit: 15 + +fn main() +{ + println!("hello, world") + ; +} + +// @generated \ No newline at end of file diff --git a/tests/target/configs/format_generated_files/false_with_marker_out_scope_size.rs b/tests/target/configs/format_generated_files/false_with_marker_out_scope_size.rs new file mode 100644 index 00000000000..93405896a1d --- /dev/null +++ b/tests/target/configs/format_generated_files/false_with_marker_out_scope_size.rs @@ -0,0 +1,8 @@ +// rustfmt-format_generated_files: false +// rustfmt-generated_marker_line_search_limit: 1 + +fn main() { + println!("hello, world"); +} + +// @generated diff --git a/tests/target/configs/format_generated_files/false_with_zero_search_limit.rs b/tests/target/configs/format_generated_files/false_with_zero_search_limit.rs new file mode 100644 index 00000000000..6acd46ed2eb --- /dev/null +++ b/tests/target/configs/format_generated_files/false_with_zero_search_limit.rs @@ -0,0 +1,8 @@ +// rustfmt-format_generated_files: false +// rustfmt-generated_marker_line_search_limit: 0 + +// @generated +fn main() { + println!("hello, world"); +} +// @generated diff --git a/tests/target/configs/format_generated_files/true_with_marker_in_scope_size.rs b/tests/target/configs/format_generated_files/true_with_marker_in_scope_size.rs new file mode 100644 index 00000000000..03bfdfd1c59 --- /dev/null +++ b/tests/target/configs/format_generated_files/true_with_marker_in_scope_size.rs @@ -0,0 +1,8 @@ +// rustfmt-format_generated_files: true +// rustfmt-generated_marker_line_search_limit: 20 + +fn main() { + println!("hello, world"); +} + +// @generated diff --git a/tests/target/configs/format_generated_files/true_with_marker_not_in_header.rs b/tests/target/configs/format_generated_files/true_with_marker_not_in_header.rs new file mode 100644 index 00000000000..3b6280b350e --- /dev/null +++ b/tests/target/configs/format_generated_files/true_with_marker_not_in_header.rs @@ -0,0 +1,7 @@ +// rustfmt-format_generated_files: true + +fn main() { + println!("hello, world"); +} + +// @generated diff --git a/tests/target/impl.rs b/tests/target/impl.rs index f37fbcf1fcb..10de0ecde56 100644 --- a/tests/target/impl.rs +++ b/tests/target/impl.rs @@ -32,6 +32,11 @@ where { } +// #5941 +impl T where (): Clone // Should not add comma to comment +{ +} + // #1823 default impl Trait for X {} default unsafe impl Trait for Y {} diff --git a/tests/target/issue-3805.rs b/tests/target/issue-3805.rs new file mode 100644 index 00000000000..a247a43fe6d --- /dev/null +++ b/tests/target/issue-3805.rs @@ -0,0 +1,94 @@ +// rustfmt-version: Two +// rustfmt-format_macro_matchers: true + +// From original issue example - Line length 101 +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr + ) => {{ + return; + }}; +} + +// Spaces between the `{` and `}` +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr + ) => {{ + return; + }}; +} + +// Multi `{}` +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr + ) => {{ + { + { + return; + } + } + }}; +} + +// Multi `{}` with spaces +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr + ) => {{ + { + { + return; + } + } + }}; +} + +// Line length 102 +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeiou:expr, $add:expr + ) => {{ + return; + }}; +} + +// Line length 103 +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeioua:expr, $add:expr + ) => {{ + return; + }}; +} + +// With extended macro body - Line length 101 +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeio:expr, $add:expr + ) => {{ + let VAR = "VALUE"; + return VAR; + }}; +} + +// With extended macro body - Line length 102 +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeiou:expr, $add:expr + ) => {{ + let VAR = "VALUE"; + return VAR; + }}; +} + +// With extended macro body - Line length 103 +macro_rules! test { + ( + $aasdfghj:expr, $qwertyuiop:expr, $zxcvbnmasdfghjkl:expr, $aeiouaeiouaeioua:expr, $add:expr + ) => {{ + let VAR = "VALUE"; + return VAR; + }}; +} diff --git a/tests/target/issue-5801/attribute_does_not_wrap_within_max_width.rs b/tests/target/issue-5801/attribute_does_not_wrap_within_max_width.rs new file mode 100644 index 00000000000..e3b6f3b37f5 --- /dev/null +++ b/tests/target/issue-5801/attribute_does_not_wrap_within_max_width.rs @@ -0,0 +1,8 @@ +// rustfmt-config: issue-5801-v2.toml + +pub enum Severity { + #[something(AAAAAAAAAAAAA, BBBBBBBBBBBBBB, CCCCCCCCCCCCCCCC, DDDDDDDDDDDDD, EEEEEEEEEEEE, FFFFFFFFFFF, GGGGGGGGGGG)] + AttrsWillWrap, + #[something_else(hhhhhhhhhhhhhhhh, iiiiiiiiiiiiiiii, jjjjjjjjjjjjjjj, kkkkkkkkkkkkk, llllllllllll, mmmmmmmmmmmmmm)] + AttrsWontWrap, +} diff --git a/tests/target/issue-5801/attribute_unexpectedly_wraps_before_max_width.rs b/tests/target/issue-5801/attribute_unexpectedly_wraps_before_max_width.rs new file mode 100644 index 00000000000..89676666225 --- /dev/null +++ b/tests/target/issue-5801/attribute_unexpectedly_wraps_before_max_width.rs @@ -0,0 +1,16 @@ +// rustfmt-config: issue-5801-v1.toml + +pub enum Severity { + #[something( + AAAAAAAAAAAAA, + BBBBBBBBBBBBBB, + CCCCCCCCCCCCCCCC, + DDDDDDDDDDDDD, + EEEEEEEEEEEE, + FFFFFFFFFFF, + GGGGGGGGGGG + )] + AttrsWillWrap, + #[something_else(hhhhhhhhhhhhhhhh, iiiiiiiiiiiiiiii, jjjjjjjjjjjjjjj, kkkkkkkkkkkkk, llllllllllll, mmmmmmmmmmmmmm)] + AttrsWontWrap, +} diff --git a/tests/target/issue-5801/comment_does_not_wrap_within_max_width.rs b/tests/target/issue-5801/comment_does_not_wrap_within_max_width.rs new file mode 100644 index 00000000000..9f294751108 --- /dev/null +++ b/tests/target/issue-5801/comment_does_not_wrap_within_max_width.rs @@ -0,0 +1,16 @@ +// rustfmt-comment_width: 120 +// rustfmt-wrap_comments: true +// rustfmt-max_width: 120 +// rustfmt-version: Two + +/// This function is 120 columns wide and is left alone. This comment is 120 columns wide and the formatter is also fine +fn my_super_cool_function_name(my_very_cool_argument_name: String, my_other_very_cool_argument_name: String) -> String { + unimplemented!() +} + +pub enum Severity { + /// But here, this comment is 120 columns wide and the formatter wants to split it up onto two separate lines still. + Error, + /// This comment is 119 columns wide and works perfectly. Lorem ipsum. lorem ipsum. lorem ipsum. lorem ipsum lorem. + Warning, +} diff --git a/tests/target/issue-5801/comment_unexpectedly_wraps_before_max_width.rs b/tests/target/issue-5801/comment_unexpectedly_wraps_before_max_width.rs new file mode 100644 index 00000000000..dd839dd4548 --- /dev/null +++ b/tests/target/issue-5801/comment_unexpectedly_wraps_before_max_width.rs @@ -0,0 +1,18 @@ +// rustfmt-comment_width: 120 +// rustfmt-wrap_comments: true +// rustfmt-max_width: 120 +// rustfmt-version: One + +/// This function is 120 columns wide and is left alone. This comment is 120 columns wide and the formatter is also fine +fn my_super_cool_function_name(my_very_cool_argument_name: String, my_other_very_cool_argument_name: String) -> String { + unimplemented!() +} + +pub enum Severity { + /// In version one, the below line got wrapped prematurely as we subtracted 1 to account for `,`. See issue #5801. + /// But here, this comment is 120 columns wide and the formatter wants to split it up onto two separate lines + /// still. + Error, + /// This comment is 119 columns wide and works perfectly. Lorem ipsum. lorem ipsum. lorem ipsum. lorem ipsum lorem. + Warning, +} diff --git a/tests/target/issue-5885.rs b/tests/target/issue-5885.rs new file mode 100644 index 00000000000..85a659cbb47 --- /dev/null +++ b/tests/target/issue-5885.rs @@ -0,0 +1,3 @@ +fn main() { + println!("{}", builtin # offset_of(A, 0. 1.1.1)); +} diff --git a/tests/target/issue-5987/one.rs b/tests/target/issue-5987/one.rs new file mode 100644 index 00000000000..3c995ed28ba --- /dev/null +++ b/tests/target/issue-5987/one.rs @@ -0,0 +1,13 @@ +// rustfmt-version: One + +fn main() { + trace!( + "get some longer length in here yes yes {} {}", + "hello", + "world" + ); + debug!( + "get some longer length in here yes yes {} {}", + "hello", "world" + ); +} diff --git a/tests/target/issue-5987/two.rs b/tests/target/issue-5987/two.rs new file mode 100644 index 00000000000..8fd92fc179e --- /dev/null +++ b/tests/target/issue-5987/two.rs @@ -0,0 +1,12 @@ +// rustfmt-version: Two + +fn main() { + trace!( + "get some longer length in here yes yes {} {}", + "hello", "world" + ); + debug!( + "get some longer length in here yes yes {} {}", + "hello", "world" + ); +} diff --git a/tests/target/issue-6059/additional.rs b/tests/target/issue-6059/additional.rs new file mode 100644 index 00000000000..fe708dcbdd3 --- /dev/null +++ b/tests/target/issue-6059/additional.rs @@ -0,0 +1,6 @@ +fn float_range_tests() { + let _range = 3. / 2. ..4.; + let _range = 3.0 / 2. ..4.0; + let _range = 3.0 / 2.0..4.0; + let _range = 3. / 2.0..4.0; +} diff --git a/tests/target/issue-6059/repro.rs b/tests/target/issue-6059/repro.rs new file mode 100644 index 00000000000..e8744c9ffcf --- /dev/null +++ b/tests/target/issue-6059/repro.rs @@ -0,0 +1,3 @@ +fn float_range_tests() { + self.coords.x -= rng.gen_range(-self.radius / 2. ..self.radius / 2.); +} diff --git a/tests/target/issue-6105.rs b/tests/target/issue-6105.rs new file mode 100644 index 00000000000..1eb0ce89f78 --- /dev/null +++ b/tests/target/issue-6105.rs @@ -0,0 +1 @@ +const _: () = builtin # offset_of(x, x); diff --git a/tests/target/issue-6147/case_rustfmt_v1.rs b/tests/target/issue-6147/case_rustfmt_v1.rs new file mode 100644 index 00000000000..75800012c63 --- /dev/null +++ b/tests/target/issue-6147/case_rustfmt_v1.rs @@ -0,0 +1,20 @@ +// rustfmt-version: One + +pub fn main() { + let a = Some(12); + match a { + #![attr1] + #![attr2] + #![attr3] + _ => None, + } + + { + match a { + #![attr1] + #![attr2] + #![attr3] + _ => None, + } + } +} diff --git a/tests/target/issue-6147/case_rustfmt_v2.rs b/tests/target/issue-6147/case_rustfmt_v2.rs new file mode 100644 index 00000000000..5e4220e7306 --- /dev/null +++ b/tests/target/issue-6147/case_rustfmt_v2.rs @@ -0,0 +1,20 @@ +// rustfmt-version: Two + +pub fn main() { + let a = Some(12); + match a { + #![attr1] + #![attr2] + #![attr3] + _ => None, + } + + { + match a { + #![attr1] + #![attr2] + #![attr3] + _ => None, + } + } +} diff --git a/tests/target/issue_5912.rs b/tests/target/issue_5912.rs new file mode 100644 index 00000000000..835f2aba971 --- /dev/null +++ b/tests/target/issue_5912.rs @@ -0,0 +1,15 @@ +// rustfmt-match_arm_blocks: false +// rustfmt-control_brace_style: AlwaysNextLine + +fn foo() { + match 0 + { + 0 => + aaaaaaaaaaaaaaaaaaaaaaaa + + bbbbbbbbbbbbbbbbbbbbbbbbb + + bbbbbbbbbbbbbbbbbbbbbbbbb + + bbbbbbbbbbbbbbbbbbbbbbbbb + + bbbbbbbbbbbbbbbbbbbbbbbbb, + _ => 2, + } +} diff --git a/tests/target/issue_6069.rs b/tests/target/issue_6069.rs new file mode 100644 index 00000000000..d866ce7c646 --- /dev/null +++ b/tests/target/issue_6069.rs @@ -0,0 +1,3 @@ +// `Foó` as written here ends with ASCII 6F `'o'` followed by `'\u{0301}'` COMBINING ACUTE ACCENT. +// The compiler normalizes that combination to NFC form, `'\u{00F3}'` LATIN SMALL LETTER O WITH ACUTE. +trait Foó: Bar {} diff --git a/tests/target/issue_6158.rs b/tests/target/issue_6158.rs new file mode 100644 index 00000000000..82bb7d9fa05 --- /dev/null +++ b/tests/target/issue_6158.rs @@ -0,0 +1,7 @@ +fn main() { + const { + #![allow(clippy::assertions_on_constants)] + + assert!(1 < 2); + } +} diff --git a/tests/target/let_else.rs b/tests/target/let_else.rs index f6560e85462..528d2929734 100644 --- a/tests/target/let_else.rs +++ b/tests/target/let_else.rs @@ -180,8 +180,8 @@ fn unbreakable_initializer_expr_pre_formatting_length_through_initializer_expr_n // Break after the `=` and put the initializer expr on it's own line. // Because the initializer expr is multi-lined the else is placed on it's own line. // The initializer expr has a length of 91, which when indented on the next line - // The `(indent)init` line has a lengh of 99. This is the max length that the `init` can be - // before we start running into max_width issues. I suspect this is becuase the shape is + // The `(indent)init` line has a length of 99. This is the max length that the `init` can be + // before we start running into max_width issues. I suspect this is because the shape is // accounting for the `;` at the end of the `let-else` statement. let Some(x) = some_really_really_really_really_really_really_really_really_really_really_long_name______I @@ -194,7 +194,7 @@ fn unbreakable_initializer_expr_pre_formatting_length_through_initializer_expr_n // Post Formatting: // Max length issues prevent us from formatting. // The initializer expr has a length of 92, which if it would be indented on the next line - // the `(indent)init` line has a lengh of 100 which == max_width of 100. + // the `(indent)init` line has a length of 100 which == max_width of 100. // One might expect formatting to succeed, but I suspect the reason we hit max_width issues is // because the Shape is accounting for the `;` at the end of the `let-else` statement. let Some(x) = some_really_really_really_really_really_really_really_really_really_really_really_long_nameJ else {return}; diff --git a/tests/target/no_arg_with_commnet.rs b/tests/target/no_arg_with_commnet.rs index 69f61b60f29..21802d87f47 100644 --- a/tests/target/no_arg_with_commnet.rs +++ b/tests/target/no_arg_with_commnet.rs @@ -1 +1 @@ -fn foo(/* cooment */) {} +fn foo(/* comment */) {} |
