rust/compiler
Eric Huss ba013373d8
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`
2022-01-30 08:37:47 -08:00
..
rustc remove unused jemallocator crate 2022-01-28 16:56:05 +01:00
rustc_apfloat Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
rustc_arena Clarify ArenaAllocatable's second parameter. 2022-01-28 07:37:10 +11:00
rustc_ast Make Decodable and Decoder infallible. 2022-01-22 10:38:31 +11:00
rustc_ast_lowering Filter out local_id == 0, those are already considered on the call site 2022-01-26 12:25:31 -03:00
rustc_ast_passes Auto merge of #92896 - lqd:update-deps, r=Mark-Simulacrum 2022-01-21 10:38:30 +00:00
rustc_ast_pretty Rollup merge of #92908 - dtolnay:rustdoc, r=GuillaumeGomez 2022-01-30 08:37:47 -08:00
rustc_attr Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
rustc_borrowck Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot 2022-01-25 18:53:45 +00:00
rustc_builtin_macros Rename _args -> args in format_args expansion 2022-01-29 12:44:41 -08:00
rustc_codegen_cranelift Use an indexmap to avoid sorting LocalDefIds 2022-01-22 22:34:16 -06:00
rustc_codegen_gcc Merge landing_pad and set_cleanup into cleanup_landing_pad 2022-01-24 14:10:05 +01:00
rustc_codegen_llvm Auto merge of #93427 - matthiaskrgr:rollup-esd3ixl, r=matthiaskrgr 2022-01-28 23:20:38 +00:00
rustc_codegen_ssa Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obk 2022-01-29 14:46:30 +01:00
rustc_const_eval Rollup merge of #93358 - compiler-errors:is-not-const, r=fee1-dead 2022-01-30 00:04:11 +01:00
rustc_data_structures Rollup merge of #93193 - Kobzol:stable-hash-permutation-test, r=the8472 2022-01-27 22:32:24 +01:00
rustc_driver Make Decodable and Decoder infallible. 2022-01-22 10:38:31 +11:00
rustc_error_codes Rollup merge of #88205 - danii:e0772, r=GuillaumeGomez 2022-01-29 14:46:29 +01:00
rustc_errors Rollup merge of #93229 - mark-i-m:noquiet, r=eddyb 2022-01-23 20:13:07 +01:00
rustc_expand Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum 2022-01-30 08:37:46 -08:00
rustc_feature update pass_by_value 2022-01-27 07:58:33 +01:00
rustc_fs_util
rustc_graphviz eplace usages of vec![].into_iter with [].into_iter 2022-01-09 14:09:25 +11:00
rustc_hir Store hir_id_to_def_id in OwnerInfo. 2022-01-25 15:05:19 -03:00
rustc_hir_pretty try apply rustc_pass_by_value to Span 2022-01-27 11:29:41 +01:00
rustc_incremental Make Decodable and Decoder infallible. 2022-01-22 10:38:31 +11:00
rustc_index Make Decodable and Decoder infallible. 2022-01-22 10:38:31 +11:00
rustc_infer do not register infer var for GAT projection in opaque 2022-01-26 22:45:12 -08:00
rustc_interface expand: Pass everything by reference to pre-expansion lint callback 2022-01-23 19:31:32 +08:00
rustc_lexer Auto merge of #91393 - Julian-Wollersberger:lexer_optimization, r=petrochenkov 2021-12-03 13:20:14 +00:00
rustc_lint Rollup merge of #93358 - compiler-errors:is-not-const, r=fee1-dead 2022-01-30 00:04:11 +01:00
rustc_lint_defs Rollup merge of #92611 - Amanieu:asm-reference, r=m-ou-se 2022-01-28 15:20:21 +01:00
rustc_llvm Use error-on-mismatch policy for PAuth module flags. 2022-01-24 16:50:10 +00:00
rustc_log Make rustc_log doc test runnable 2022-01-03 22:31:56 -08:00
rustc_macros Make Decodable and Decoder infallible. 2022-01-22 10:38:31 +11:00
rustc_metadata Auto merge of #88679 - petrochenkov:doctrscope, r=GuillaumeGomez 2022-01-26 09:10:27 +00:00
rustc_middle Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum 2022-01-30 08:37:46 -08:00
rustc_mir_build Ignore unwinding edges when checking for unconditional recursion 2022-01-26 13:46:01 +01:00
rustc_mir_dataflow Remove deprecated LLVM-style inline assembly 2022-01-12 18:51:31 +01:00
rustc_mir_transform try apply rustc_pass_by_value to Span 2022-01-27 11:29:41 +01:00
rustc_monomorphize Change TerminatorKind::Abort to call the panic handler instead of 2022-01-17 00:39:34 +00:00
rustc_parse Introduce a limit to Levenshtein distance computation 2022-01-26 12:38:22 +01:00
rustc_parse_format
rustc_passes Reject unsupported naked functions 2022-01-21 17:38:21 +01:00
rustc_plugin_impl replace dynamic library module with libloading 2021-12-06 12:03:47 -05:00
rustc_privacy Remove a span from hir::ExprKind::MethodCall 2022-01-21 07:48:10 -06:00
rustc_query_impl Make Decodable and Decoder infallible. 2022-01-22 10:38:31 +11:00
rustc_query_system Address review comments. 2022-01-22 10:38:34 +11:00
rustc_resolve rustdoc: Pre-calculate traits that are in scope for doc links 2022-01-25 21:45:21 +08:00
rustc_save_analysis Remove a span from hir::ExprKind::MethodCall 2022-01-21 07:48:10 -06:00
rustc_serialize Auto merge of #90842 - pierwill:localdefid-indexmap, r=wesleywiser 2022-01-24 22:04:55 +00:00
rustc_session Rollup merge of #93229 - mark-i-m:noquiet, r=eddyb 2022-01-23 20:13:07 +01:00
rustc_span Rename _args -> args in format_args expansion 2022-01-29 12:44:41 -08:00
rustc_symbol_mangling Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot 2022-01-25 18:53:45 +00:00
rustc_target Add preliminary support for inline assembly for msp430. 2022-01-22 23:42:46 -05:00
rustc_trait_selection Rollup merge of #93358 - compiler-errors:is-not-const, r=fee1-dead 2022-01-30 00:04:11 +01:00
rustc_traits ⬆ chalk to 0.76.0 2022-01-19 13:44:43 -06:00
rustc_ty_utils Store a Symbol instead of an Ident in AssocItem 2022-01-19 17:13:21 -05:00
rustc_type_ir initial revert 2022-01-15 01:16:55 +00:00
rustc_typeck Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obk 2022-01-29 14:46:30 +01:00