Skip to content

Commit 399d025

Browse files
committed
return when span is start span
1 parent 06251e3 commit 399d025

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/missed_spans.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ impl<'a> FmtVisitor<'a> {
100100
}
101101

102102
if snippet.trim().is_empty() && !out_of_file_lines_range!(self, span) {
103+
if self.is_start_span(span) {
104+
return;
105+
}
106+
103107
// Keep vertical spaces within range.
104108
self.push_vertical_spaces(count_newlines(snippet));
105109
process_last_snippet(self, "", snippet);

src/visitor.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ impl SnippetProvider {
4646
Some(&self.big_snippet[start_index..end_index])
4747
}
4848

49+
pub(crate) fn is_start_span(&self, span: Span) -> bool {
50+
span.lo().to_usize() == self.start_pos
51+
}
52+
4953
pub(crate) fn new(start_pos: BytePos, end_pos: BytePos, big_snippet: Rc<String>) -> Self {
5054
let start_pos = start_pos.to_usize();
5155
let end_pos = end_pos.to_usize();
@@ -751,6 +755,10 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
751755
self.opt_snippet(span).unwrap()
752756
}
753757

758+
pub(crate) fn is_start_span(&'b self, span: Span) -> bool {
759+
self.snippet_provider.is_start_span(span)
760+
}
761+
754762
// Returns true if we should skip the following item.
755763
pub(crate) fn visit_attrs(&mut self, attrs: &[ast::Attribute], style: ast::AttrStyle) -> bool {
756764
for attr in attrs {

0 commit comments

Comments
 (0)