From c93c771e71ca96a94ab7d13b37103cb57be22df5 Mon Sep 17 00:00:00 2001 From: Marcus Klaas Date: Fri, 13 Nov 2015 14:53:34 +0100 Subject: [PATCH] Fix span issue with generic method calls --- src/chains.rs | 10 ++++++---- tests/source/chains.rs | 6 ++++++ tests/target/chains.rs | 6 ++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/chains.rs b/src/chains.rs index f004a5798c2..9c5b37d35cb 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -217,15 +217,17 @@ fn rewrite_method_call(method_name: ast::Ident, width: usize, offset: Indent) -> Option { - let type_str = if types.is_empty() { - String::new() + let (lo, type_str) = if types.is_empty() { + (args[0].span.hi, String::new()) } else { let type_list = types.iter().map(|ty| pprust::ty_to_string(ty)).collect::>(); - format!("::<{}>", type_list.join(", ")) + + (types.last().unwrap().span.hi, + format!("::<{}>", type_list.join(", "))) }; let callee_str = format!(".{}{}", method_name, type_str); - let span = mk_sp(args[0].span.hi, span.hi); + let span = mk_sp(lo, span.hi); rewrite_call(context, &callee_str, &args[1..], span, width, offset) } diff --git a/tests/source/chains.rs b/tests/source/chains.rs index bf1ed31afe7..e7d9783a51c 100644 --- a/tests/source/chains.rs +++ b/tests/source/chains.rs @@ -106,3 +106,9 @@ fn is_replaced_content() -> bool { constellat.send(ConstellationMsg::ViewportConstrained( self.id, constraints)).unwrap(); } + +fn issue587() { + a.b::<()>(c); + + std::mem::transmute(dl.symbol::<()>("init").unwrap()) +} diff --git a/tests/target/chains.rs b/tests/target/chains.rs index 2fb201011a5..d8fca6d40fe 100644 --- a/tests/target/chains.rs +++ b/tests/target/chains.rs @@ -132,3 +132,9 @@ fn is_replaced_content() -> bool { constellat.send(ConstellationMsg::ViewportConstrained(self.id, constraints)) .unwrap(); } + +fn issue587() { + a.b::<()>(c); + + std::mem::transmute(dl.symbol::<()>("init").unwrap()) +}