about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2015-02-20 18:33:29 +0200
committerEduard Burtescu <edy.burt@gmail.com>2015-02-24 14:16:02 +0200
commitf0efa2d84347ed0081476f04f42efe4be85ae4d6 (patch)
tree515c688c64cdd95ebaaa4d459c1314a256a1e491
parent9ac073604c6689a773eb19bcc375234384326682 (diff)
downloadrust-f0efa2d84347ed0081476f04f42efe4be85ae4d6.tar.gz
rust-f0efa2d84347ed0081476f04f42efe4be85ae4d6.zip
Update trans/save's span hacks for fully qualified UFCS paths.
-rw-r--r--src/librustc_trans/save/span_utils.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/librustc_trans/save/span_utils.rs b/src/librustc_trans/save/span_utils.rs
index a5bebaa257c..8de046fa6eb 100644
--- a/src/librustc_trans/save/span_utils.rs
+++ b/src/librustc_trans/save/span_utils.rs
@@ -238,6 +238,7 @@ impl<'a> SpanUtils<'a> {
         let mut toks = self.retokenise_span(span);
         // We keep track of how many brackets we're nested in
         let mut bracket_count = 0;
+        let mut found_ufcs_sep = false;
         loop {
             let ts = toks.real_token();
             if ts.tok == token::Eof {
@@ -254,13 +255,20 @@ impl<'a> SpanUtils<'a> {
             }
             bracket_count += match ts.tok {
                 token::Lt => 1,
-                token::Gt => -1,
+                token::Gt => {
+                    // Ignore the `>::` in `<Type as Trait>::AssocTy`.
+                    if !found_ufcs_sep && bracket_count == 0 {
+                        found_ufcs_sep = true;
+                        0
+                    } else {
+                        -1
+                    }
+                }
                 token::BinOp(token::Shl) => 2,
                 token::BinOp(token::Shr) => -2,
                 _ => 0
             };
-            if ts.tok.is_ident() &&
-               bracket_count == nesting {
+            if ts.tok.is_ident() && bracket_count == nesting {
                 result.push(self.make_sub_span(span, Some(ts.sp)).unwrap());
             }
         }