Skip to content

Commit

Permalink
Fix how we get span of the PathSegment separator
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed Feb 6, 2019
1 parent f4f9502 commit 6541f20
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,14 @@ fn rewrite_segment(
.chain(data.bindings.iter().map(|x| SegmentParam::Binding(&*x)))
.collect::<Vec<_>>();

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

0 comments on commit 6541f20

Please sign in to comment.