Rollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkov
Show invisible delimeters (within comments) when pretty printing. Because invisible syntax is really hard to work with! r? `@petrochenkov`
This commit is contained in:
commit
7a915dd80d
17 changed files with 110 additions and 68 deletions
|
@ -590,15 +590,29 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
|
|||
self.nbsp();
|
||||
}
|
||||
self.word("{");
|
||||
if !tts.is_empty() {
|
||||
let empty = tts.is_empty();
|
||||
if !empty {
|
||||
self.space();
|
||||
}
|
||||
self.ibox(0);
|
||||
self.print_tts(tts, convert_dollar_crate);
|
||||
self.end();
|
||||
let empty = tts.is_empty();
|
||||
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("/*»*/");
|
||||
}
|
||||
Some(delim) => {
|
||||
let token_str = self.token_kind_to_string(&token::OpenDelim(delim));
|
||||
self.word(token_str);
|
||||
|
@ -772,9 +786,8 @@ 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) | token::CloseDelim(Delimiter::Invisible) => {
|
||||
"".into()
|
||||
}
|
||||
token::OpenDelim(Delimiter::Invisible) => "/*«*/".into(),
|
||||
token::CloseDelim(Delimiter::Invisible) => "/*»*/".into(),
|
||||
token::Pound => "#".into(),
|
||||
token::Dollar => "$".into(),
|
||||
token::Question => "?".into(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue