• Y
    Rollup merge of #98183 - dtolnay:emptybound, r=lcnr · b6fb582c
    Yuki Okushi 提交于
    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 `:`
    ```
    b6fb582c
diagnostics.rs 108.4 KB