Skip to content

Commit f0efa2d

Browse files
committed
Update trans/save's span hacks for fully qualified UFCS paths.
1 parent 9ac0736 commit f0efa2d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/librustc_trans/save/span_utils.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ impl<'a> SpanUtils<'a> {
238238
let mut toks = self.retokenise_span(span);
239239
// We keep track of how many brackets we're nested in
240240
let mut bracket_count = 0;
241+
let mut found_ufcs_sep = false;
241242
loop {
242243
let ts = toks.real_token();
243244
if ts.tok == token::Eof {
@@ -254,13 +255,20 @@ impl<'a> SpanUtils<'a> {
254255
}
255256
bracket_count += match ts.tok {
256257
token::Lt => 1,
257-
token::Gt => -1,
258+
token::Gt => {
259+
// Ignore the `>::` in `<Type as Trait>::AssocTy`.
260+
if !found_ufcs_sep && bracket_count == 0 {
261+
found_ufcs_sep = true;
262+
0
263+
} else {
264+
-1
265+
}
266+
}
258267
token::BinOp(token::Shl) => 2,
259268
token::BinOp(token::Shr) => -2,
260269
_ => 0
261270
};
262-
if ts.tok.is_ident() &&
263-
bracket_count == nesting {
271+
if ts.tok.is_ident() && bracket_count == nesting {
264272
result.push(self.make_sub_span(span, Some(ts.sp)).unwrap());
265273
}
266274
}

0 commit comments

Comments
 (0)