Skip to content

Commit 044dec4

Browse files
committed
Fix pretty printer when there are multiple lifetime parameters
1 parent 98f7973 commit 044dec4

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/libsyntax/print/pprust.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -1572,17 +1572,24 @@ fn print_path_(s: @ps,
15721572
}
15731573
word(s.s, "<");
15741574

1575+
let mut comma = false;
15751576
for lifetime in segment.lifetimes.iter() {
1576-
print_lifetime(s, lifetime);
1577-
if !segment.types.is_empty() {
1577+
if comma {
15781578
word_space(s, ",")
15791579
}
1580+
print_lifetime(s, lifetime);
1581+
comma = true;
15801582
}
15811583

1582-
commasep(s,
1583-
inconsistent,
1584-
segment.types.map_to_vec(|t| (*t).clone()),
1585-
print_type);
1584+
if !segment.types.is_empty() {
1585+
if comma {
1586+
word_space(s, ",")
1587+
}
1588+
commasep(s,
1589+
inconsistent,
1590+
segment.types.map_to_vec(|t| (*t).clone()),
1591+
print_type);
1592+
}
15861593

15871594
word(s.s, ">")
15881595
}

src/test/compile-fail/regions-variance-invariant-use-contravariant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn use_<'short,'long>(c: Invariant<'long>,
2727
// 'short <= 'long, this would be true if the Invariant type were
2828
// contravariant with respect to its parameter 'a.
2929

30-
let _: Invariant<'short> = c; //~ ERROR lifetime mistach
30+
let _: Invariant<'short> = c; //~ ERROR mismatched types
3131
}
3232

3333
fn main() { }

0 commit comments

Comments
 (0)