]> git.lizzy.rs Git - rust.git/commitdiff
Update trans/save's span hacks for fully qualified UFCS paths.
authorEduard Burtescu <edy.burt@gmail.com>
Fri, 20 Feb 2015 16:33:29 +0000 (18:33 +0200)
committerEduard Burtescu <edy.burt@gmail.com>
Tue, 24 Feb 2015 12:16:02 +0000 (14:16 +0200)
src/librustc_trans/save/span_utils.rs

index a5bebaa257ca0ca80b192afa37223ab1e6289279..8de046fa6ebb6c8486604be025597ffd6684a976 100644 (file)
@@ -238,6 +238,7 @@ pub fn spans_with_brackets(&self, span: Span, nesting: int, limit: int) -> Vec<S
         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 @@ pub fn spans_with_brackets(&self, span: Span, nesting: int, limit: int) -> Vec<S
             }
             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());
             }
         }