Skip to content

Commit 6541f20

Browse files
committed
Fix how we get span of the PathSegment separator
1 parent f4f9502 commit 6541f20

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/types.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,14 @@ fn rewrite_segment(
229229
.chain(data.bindings.iter().map(|x| SegmentParam::Binding(&*x)))
230230
.collect::<Vec<_>>();
231231

232-
let force_separator =
233-
context.inside_macro() && context.snippet(data.span).starts_with("::");
232+
// HACK: squeeze out the span between the identifier and the parameters.
233+
// The hack is requried so that we don't remove the separator inside macro calls.
234+
// This does not work in the presence of comment, hoping that people are
235+
// sane about where to put their comment.
236+
let separator_snippet = context
237+
.snippet(mk_sp(segment.ident.span.hi(), data.span.lo()))
238+
.trim();
239+
let force_separator = context.inside_macro() && separator_snippet.starts_with("::");
234240
let separator = if path_context == PathContext::Expr || force_separator {
235241
"::"
236242
} else {

0 commit comments

Comments
 (0)