Merge pull request #282 from marcusklaas/qself-fix

Fix qself rewrites without explicit casts
This commit is contained in:
Nick Cameron 2015-09-07 09:35:29 +12:00
commit 2a61a989d5
3 changed files with 18 additions and 11 deletions

View File

@ -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;
if skip_count > 0 {
result.push_str(" as ");
result = try_opt!(rewrite_path_segments(result,
path.segments.iter().take(skip_count),
span_lo,
path.span.hi,
context,
budget,
offset + extra_offset));
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);

View File

@ -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 {}

View File

@ -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 {