mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
082cdf7c48
The AST pretty printer strips braces from single-item `use` sub-groups,
simplifying `use foo::{Bar}` to `use foo::Bar`. However, when the single
item is `self`, this produces `use foo::self` which is not valid Rust
(E0429) — the grammar requires `use foo::{self}`.
This affects both `stringify!` and `rustc -Zunpretty=expanded`, causing
`cargo expand` output to be unparseable when a crate uses `use
path::{self}` imports (a common pattern in the ecosystem).
The fix checks whether the single nested item's path starts with `self`
before stripping braces. If so, the braces are preserved.
Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
11 lines
208 B
Rust
11 lines
208 B
Rust
//@ pp-exact
|
|
//@ edition:2021
|
|
|
|
#![allow(unused_imports)]
|
|
|
|
// Braces around `self` must be preserved, because `use foo::self` is not valid Rust.
|
|
use std::io::{self};
|
|
use std::fmt::{self, Debug};
|
|
|
|
fn main() {}
|