@@ -792,12 +792,6 @@ pub(crate) fn format_code_block(code_snippet: &str, config: &Config) -> Option<F
792
792
}
793
793
let trimmed_line = if !is_indented {
794
794
line
795
- } else if line. len ( ) > config. max_width ( ) {
796
- // If there are lines that are larger than max width, we cannot tell
797
- // whether we have succeeded but have some comments or strings that
798
- // are too long, or we have failed to format code block. We will be
799
- // conservative and just return `None` in this case.
800
- return None ;
801
795
} else if line. len ( ) > indent_str. len ( ) {
802
796
// Make sure that the line has leading whitespaces.
803
797
if line. starts_with ( indent_str. as_ref ( ) ) {
@@ -885,13 +879,6 @@ mod test {
885
879
assert ! ( test_format_inner( format_snippet, snippet, expected) ) ;
886
880
}
887
881
888
- #[ test]
889
- fn test_format_code_block_fail ( ) {
890
- #[ rustfmt:: skip]
891
- let code_block = "this_line_is_100_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(x, y, z);" ;
892
- assert ! ( format_code_block( code_block, & Config :: default ( ) ) . is_none( ) ) ;
893
- }
894
-
895
882
#[ test]
896
883
fn test_format_code_block ( ) {
897
884
// simple code block
@@ -942,5 +929,11 @@ false,
942
929
)
943
930
};" ;
944
931
assert ! ( test_format_inner( format_code_block, code_block, expected) ) ;
932
+
933
+ #[ rustfmt:: skip]
934
+ let code_block = "this_line_is_100_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(x, y, z);" ;
935
+ #[ rustfmt:: skip]
936
+ let expected = "this_line_is_100_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(x, y, z);" ;
937
+ assert ! ( test_format_inner( format_code_block, code_block, expected) ) ;
945
938
}
946
939
}
0 commit comments