Commit b6fb582
authored
Rollup merge of rust-lang#98183 - dtolnay:emptybound, r=lcnr
Fix pretty printing of empty bound lists in where-clause
Repro:
```rust
macro_rules! assert_item_stringify {
($item:item $expected:literal) => {
assert_eq!(stringify!($item), $expected);
};
}
fn main() {
assert_item_stringify! {
fn f<'a, T>() where 'a:, T: {}
"fn f<'a, T>() where 'a:, T: {}"
}
}
```
Previously this assertion would fail because rustc renders the where-clause as `where 'a, T` which is invalid syntax.
This PR makes the above assertion pass.
This bug also affects `-Zunpretty=expanded`. The intention is for that to emit syntactically valid code, but the buggy output is not valid Rust syntax.
```console
$ rustc <(echo "fn f<'a, T>() where 'a:, T: {}") -Zunpretty=expanded
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
fn f<'a, T>() where 'a, T {}
```
```console
$ rustc <(echo "fn f<'a, T>() where 'a:, T: {}") -Zunpretty=expanded | rustc -
error: expected `:`, found `,`
--> <anon>:7:23
|
7 | fn f<'a, T>() where 'a, T {}
| ^ expected `:`
```File tree
4 files changed
+79
-50
lines changed- compiler
- rustc_ast_pretty/src/pprust
- state
- rustc_parse/src/parser
- src/test/pretty
4 files changed
+79
-50
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
818 | 818 | | |
819 | 819 | | |
820 | 820 | | |
| |||
991 | 991 | | |
992 | 992 | | |
993 | 993 | | |
994 | | - | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
995 | 1000 | | |
996 | 1001 | | |
997 | 1002 | | |
| |||
1045 | 1050 | | |
1046 | 1051 | | |
1047 | 1052 | | |
1048 | | - | |
1049 | | - | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
1050 | 1057 | | |
1051 | 1058 | | |
1052 | | - | |
| 1059 | + | |
| 1060 | + | |
1053 | 1061 | | |
1054 | 1062 | | |
1055 | 1063 | | |
| |||
1549 | 1557 | | |
1550 | 1558 | | |
1551 | 1559 | | |
1552 | | - | |
1553 | | - | |
1554 | | - | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
1565 | 1569 | | |
1566 | | - | |
1567 | | - | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
1571 | | - | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
1572 | 1574 | | |
1573 | | - | |
| 1575 | + | |
1574 | 1576 | | |
| 1577 | + | |
1575 | 1578 | | |
1576 | 1579 | | |
1577 | 1580 | | |
| |||
1580 | 1583 | | |
1581 | 1584 | | |
1582 | 1585 | | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
1599 | 1594 | | |
1600 | 1595 | | |
1601 | 1596 | | |
| |||
1613 | 1608 | | |
1614 | 1609 | | |
1615 | 1610 | | |
1616 | | - | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
1617 | 1616 | | |
1618 | 1617 | | |
1619 | 1618 | | |
1620 | | - | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
1621 | 1623 | | |
1622 | 1624 | | |
1623 | 1625 | | |
| |||
1630 | 1632 | | |
1631 | 1633 | | |
1632 | 1634 | | |
1633 | | - | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
1634 | 1639 | | |
1635 | 1640 | | |
1636 | 1641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
| |||
320 | 323 | | |
321 | 324 | | |
322 | 325 | | |
323 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
324 | 330 | | |
325 | 331 | | |
326 | 332 | | |
| |||
347 | 353 | | |
348 | 354 | | |
349 | 355 | | |
350 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
351 | 360 | | |
352 | 361 | | |
353 | 362 | | |
| |||
618 | 627 | | |
619 | 628 | | |
620 | 629 | | |
621 | | - | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
622 | 635 | | |
623 | 636 | | |
624 | 637 | | |
625 | 638 | | |
626 | 639 | | |
627 | 640 | | |
628 | | - | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
629 | 647 | | |
630 | 648 | | |
631 | 649 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1355 | 1355 | | |
1356 | 1356 | | |
1357 | 1357 | | |
1358 | | - | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
1359 | 1362 | | |
1360 | 1363 | | |
1361 | 1364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
0 commit comments