diff options
| author | Nick Cameron <nrc@ncameron.org> | 2015-09-07 09:35:29 +1200 |
|---|---|---|
| committer | Nick Cameron <nrc@ncameron.org> | 2015-09-07 09:35:29 +1200 |
| commit | 2a61a989d5074069cf63abd4364470c1d0780da6 (patch) | |
| tree | 33a804b283a8040c7bddf35d63662f0dee46b82c | |
| parent | 072c54beba5f81dc028428c1a3e88290cfbcc935 (diff) | |
| parent | c3cb348169474b8e75a7f7deb8f532b67a84a7f9 (diff) | |
Merge pull request #282 from marcusklaas/qself-fix
Fix qself rewrites without explicit casts
| -rw-r--r-- | src/types.rs | 29 | ||||
| -rw-r--r-- | tests/source/paths.rs | 2 | ||||
| -rw-r--r-- | tests/target/paths.rs | 2 |
3 files changed, 20 insertions, 13 deletions
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); diff --git a/tests/source/paths.rs b/tests/source/paths.rs index 51edf707645..d2b4a66622a 100644 --- a/tests/source/paths.rs +++ b/tests/source/paths.rs @@ -15,6 +15,8 @@ fn main() { Quux::<ParamOne, // Comment 1 ParamTwo, // Comment 2 >::some_func(); + + < *mut JSObject >:: relocate(entry); } fn op(foo: Bar, key : &[u8], upd : Fn(Option<&memcache::Item> , Baz ) -> Result) -> MapResult {} diff --git a/tests/target/paths.rs b/tests/target/paths.rs index c69275c7ff9..4fa3a52fe6c 100644 --- a/tests/target/paths.rs +++ b/tests/target/paths.rs @@ -13,6 +13,8 @@ fn main() { supports_clipboard); Quux::<ParamOne /* Comment 1 */, ParamTwo /* Comment 2 */>::some_func(); + + <*mut JSObject>::relocate(entry); } fn op(foo: Bar, key: &[u8], upd: Fn(Option<&memcache::Item>, Baz) -> Result) -> MapResult { |
