X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftypes.rs;h=dfb7f255a987643fe2783b63adfc6d2cafdddc89;hb=c3cb348169474b8e75a7f7deb8f532b67a84a7f9;hp=0c0d9e54424ae74596adc5ff05b0578db1f1f6e4;hpb=072c54beba5f81dc028428c1a3e88290cfbcc935;p=rust.git diff --git a/src/types.rs b/src/types.rs index 0c0d9e54424..dfb7f255a98 100644 --- a/src/types.rs +++ b/src/types.rs @@ -42,19 +42,22 @@ pub fn rewrite_path(context: &RewriteContext, if let Some(ref qself) = qself { result.push('<'); result.push_str(&pprust::ty_to_string(&qself.ty)); - result.push_str(" as "); - - let extra_offset = extra_offset(&result, offset); - // 3 = ">::".len() - let budget = try_opt!(width.checked_sub(extra_offset)) - 3; - - result = try_opt!(rewrite_path_segments(result, - path.segments.iter().take(skip_count), - span_lo, - path.span.hi, - context, - budget, - offset + extra_offset)); + + if skip_count > 0 { + result.push_str(" as "); + + let extra_offset = extra_offset(&result, offset); + // 3 = ">::".len() + let budget = try_opt!(width.checked_sub(extra_offset)) - 3; + + result = try_opt!(rewrite_path_segments(result, + path.segments.iter().take(skip_count), + span_lo, + path.span.hi, + context, + budget, + offset + extra_offset)); + } result.push_str(">::"); span_lo = qself.ty.span.hi + BytePos(1);