Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 789a097

Browse files
rchaser53topecongiro
authored andcommitted
fix internal error when using rustfmt::skip with newline on stmt (rust-lang#3785)
1 parent dfe87fe commit 789a097

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/expr.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,11 @@ pub(crate) fn rewrite_block_with_visitor(
516516
let inner_attrs = attrs.map(inner_attributes);
517517
let label_str = rewrite_label(label);
518518
visitor.visit_block(block, inner_attrs.as_ref().map(|a| &**a), has_braces);
519+
let visitor_context = visitor.get_context();
520+
context
521+
.skipped_range
522+
.borrow_mut()
523+
.append(&mut visitor_context.skipped_range.borrow_mut());
519524
Some(format!("{}{}{}", prefix, label_str, visitor.buffer))
520525
}
521526

tests/target/issue-3717.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
{
3+
#[rustfmt::skip]
4+
let _ =
5+
[1];
6+
}
7+
}

0 commit comments

Comments
 (0)