Fix how we get span of the PathSegment separator
This commit is contained in:
parent
f4f9502ea7
commit
6541f200c9
1 changed files with 8 additions and 2 deletions
10
src/types.rs
10
src/types.rs
|
@ -229,8 +229,14 @@ fn rewrite_segment(
|
||||||
.chain(data.bindings.iter().map(|x| SegmentParam::Binding(&*x)))
|
.chain(data.bindings.iter().map(|x| SegmentParam::Binding(&*x)))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let force_separator =
|
// HACK: squeeze out the span between the identifier and the parameters.
|
||||||
context.inside_macro() && context.snippet(data.span).starts_with("::");
|
// 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 {
|
let separator = if path_context == PathContext::Expr || force_separator {
|
||||||
"::"
|
"::"
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue