diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-06-02 10:49:22 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-06-02 11:22:16 +1000 |
| commit | 77e1069a5dfcc662ca2b0e731fa2fca2b6ee073b (patch) | |
| tree | 981e81642a2d4f6e4d8bf4234ce4cffe95ca501c /compiler | |
| parent | bef2b7cd1c7bcb3393f10d5752fcf9ee3026bce8 (diff) | |
| download | rust-77e1069a5dfcc662ca2b0e731fa2fca2b6ee073b.tar.gz rust-77e1069a5dfcc662ca2b0e731fa2fca2b6ee073b.zip | |
Revert #96682.
The change was "Show invisible delimiters (within comments) when pretty printing". It's useful to show these delimiters, but is a breaking change for some proc macros. Fixes #97608.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast/src/token.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 23 |
2 files changed, 7 insertions, 21 deletions
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 1522d12cbf9..85d9687c600 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -50,12 +50,11 @@ pub enum Delimiter { Brace, /// `[ ... ]` Bracket, - /// `/*«*/ ... /*»*/` + /// `Ø ... Ø` /// An invisible delimiter, that may, for example, appear around tokens coming from a /// "macro variable" `$var`. It is important to preserve operator priorities in cases like /// `$var * 3` where `$var` is `1 + 2`. - /// Invisible delimiters are not directly writable in normal Rust code except as comments. - /// Therefore, they might not survive a roundtrip of a token stream through a string. + /// Invisible delimiters might not survive roundtrip of a token stream through a string. Invisible, } diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 7357ddf2134..b80a553b418 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -590,28 +590,14 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere self.nbsp(); } self.word("{"); - let empty = tts.is_empty(); - if !empty { + if !tts.is_empty() { self.space(); } self.ibox(0); self.print_tts(tts, convert_dollar_crate); self.end(); - self.bclose(span, empty); - } - Some(Delimiter::Invisible) => { - self.word("/*«*/"); let empty = tts.is_empty(); - if !empty { - self.space(); - } - self.ibox(0); - self.print_tts(tts, convert_dollar_crate); - self.end(); - if !empty { - self.space(); - } - self.word("/*»*/"); + self.bclose(span, empty); } Some(delim) => { let token_str = self.token_kind_to_string(&token::OpenDelim(delim)); @@ -786,8 +772,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere token::CloseDelim(Delimiter::Bracket) => "]".into(), token::OpenDelim(Delimiter::Brace) => "{".into(), token::CloseDelim(Delimiter::Brace) => "}".into(), - token::OpenDelim(Delimiter::Invisible) => "/*«*/".into(), - token::CloseDelim(Delimiter::Invisible) => "/*»*/".into(), + token::OpenDelim(Delimiter::Invisible) | token::CloseDelim(Delimiter::Invisible) => { + "".into() + } token::Pound => "#".into(), token::Dollar => "$".into(), token::Question => "?".into(), |
