File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -319,6 +319,7 @@ fn rewrite_comment_inner(
319
319
320
320
let mut result = opener. to_owned ( ) ;
321
321
let mut is_prev_line_multi_line = false ;
322
+ let mut inside_code_block = false ;
322
323
let comment_line_separator = format ! ( "\n {}{}" , indent_str, line_start) ;
323
324
for line in lines {
324
325
if result == opener {
@@ -331,6 +332,14 @@ fn rewrite_comment_inner(
331
332
result. push_str ( & comment_line_separator) ;
332
333
}
333
334
335
+ if line. starts_with ( "```" ) {
336
+ inside_code_block = !inside_code_block;
337
+ }
338
+ if inside_code_block {
339
+ result. push_str ( line) ;
340
+ continue ;
341
+ }
342
+
334
343
if config. wrap_comments ( ) && line. len ( ) > fmt. shape . width && !has_url ( line) {
335
344
match rewrite_string ( line, & fmt, Some ( max_chars) ) {
336
345
Some ( ref s) => {
Original file line number Diff line number Diff line change
1
+ // rustfmt-max_width: 79
2
+ // rustfmt-wrap_comments: true
3
+ // rustfmt-error_on_line_overflow: false
4
+
5
+ /// ```rust
6
+ /// unsafe fn sum_sse2(x: i32x4) -> i32 {
7
+ /// let x = vendor::_mm_add_epi32(x, vendor::_mm_srli_si128(x.into(), 8).into());
8
+ /// let x = vendor::_mm_add_epi32(x, vendor::_mm_srli_si128(x.into(), 4).into());
9
+ /// vendor::_mm_cvtsi128_si32(x)
10
+ /// }
11
+ /// ```
12
+ fn foo ( ) { }
You can’t perform that action at this time.
0 commit comments