about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2022-01-30 08:37:47 -0800
committerGitHub <noreply@github.com>2022-01-30 08:37:47 -0800
commitba013373d8aad473d2b6c6c90bb876cd45f53164 (patch)
tree6f271c8cd82df3e3f2eb53c1f9a18f60acf1dcdf /compiler/rustc_codegen_llvm/src
parent0610d4fa66f95fa3a4a7af86239976ed668bab0e (diff)
parent039a058306b04b85a518db317304d1c25d516784 (diff)
downloadrust-ba013373d8aad473d2b6c6c90bb876cd45f53164.tar.gz
rust-ba013373d8aad473d2b6c6c90bb876cd45f53164.zip
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

![Screenshot from 2022-01-14 13-05-53](https://user-images.githubusercontent.com/1940490/149585105-1f182b78-751f-421f-a234-9dbc04fa3bbd.png)

## After

![Screenshot from 2022-01-14 13-06-04](https://user-images.githubusercontent.com/1940490/149585118-d4b52ea7-3e67-4b6e-a12b-31dfb8172f86.png)

r? `@camelid`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions