Rollup merge of #92908 - dtolnay:rustdoc, r=GuillaumeGomez
Render more readable macro matcher tokens in rustdoc Follow-up to #92334. This PR lifts some of the token rendering logic from https://github.com/dtolnay/prettyplease into rustdoc so that even the matchers for which a source code snippet is not available (because they are macro-generated, or any other reason) follow some baseline good assumptions about where the tokens in the macro matcher are appropriate to space. The below screenshots show an example of the difference using one of the gnarliest macros I could find. Some things to notice: - In the **before**, notice how a couple places break in between `$(....)`↵`*`, which is just about the worst possible place that it could break. - In the **before**, the lines that wrapped are weirdly indented by 1 space of indentation relative to column 0. In the **after**, we use the typical way of block indenting in Rust syntax which is put the open/close delimiters on their own line and indent their contents by 4 spaces relative to the previous line (so 8 spaces relative to column 0, because the matcher itself is indented by 4 relative to the `macro_rules` header). - In the **after**, macro_rules metavariables like `$tokens:tt` are kept together, which is how just about everybody writing Rust today writes them. ## Before  ## After  r? `@camelid`
This commit is contained in:
commit
ba013373d8
7 changed files with 296 additions and 61 deletions
|
@ -457,7 +457,7 @@ impl Printer {
|
|||
self.break_offset(n, 0)
|
||||
}
|
||||
|
||||
crate fn zerobreak(&mut self) {
|
||||
pub fn zerobreak(&mut self) {
|
||||
self.spaces(0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue