rust/compiler
Trevor Gross 6a1c10bd85 Add a simple markdown parser for formatting rustc --explain
Currently, the output of `rustc --explain foo` displays the raw markdown in a
pager. This is acceptable, but using actual formatting makes it easier to
understand.

This patch consists of three major components:

1.  A markdown parser. This is an extremely simple non-backtracking recursive
    implementation that requires normalization of the final token stream
2.  A utility to write the token stream to an output buffer
3.  Configuration within rustc_driver_impl to invoke this combination for
    `--explain`. Like the current implementation, it first attempts to print to
    a pager with a fallback colorized terminal, and standard print as a last
    resort.

    If color is disabled, or if the output does not support it, or if printing
    with color fails, it will write the raw markdown (which matches current
    behavior).

    Pagers known to support color are: `less` (with `-r`), `bat` (aka `catbat`),
    and `delta`.

The markdown parser does not support the entire markdown specification, but
should support the following with reasonable accuracy:

-   Headings, including formatting
-   Comments
-   Code, inline and fenced block (no indented block)
-   Strong, emphasis, and strikethrough formatted text
-   Links, anchor, inline, and reference-style
-   Horizontal rules
-   Unordered and ordered list items, including formatting

This parser and writer should be reusable by other systems if ever needed.
2023-07-03 16:04:18 -04:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Auto merge of #112062 - lukas-code:unsized-layout, r=wesleywiser 2023-06-13 22:34:59 +00:00
rustc_apfloat
rustc_arena Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
rustc_ast Syntatically accept become expressions 2023-06-19 12:54:34 +00:00
rustc_ast_lowering Do not generate lifetime_mapping for RPIT no in_trait 2023-06-29 14:26:28 -03:00
rustc_ast_passes Auto merge of #113105 - matthiaskrgr:rollup-rci0uym, r=matthiaskrgr 2023-06-27 21:31:47 +00:00
rustc_ast_pretty Syntatically accept become expressions 2023-06-19 12:54:34 +00:00
rustc_attr Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00
rustc_baked_icu_data Regen baked data 2023-05-02 10:45:16 -07:00
rustc_borrowck don't suggest move for borrows that aren't closures 2023-06-28 23:56:58 +02:00
rustc_builtin_macros Auto merge of #112802 - lukas-code:fancy-bool, r=Nilstrieb 2023-06-24 11:43:41 +00:00
rustc_codegen_cranelift Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk 2023-06-30 00:35:19 +00:00
rustc_codegen_gcc Auto merge of #112814 - antoyo:sync-cg_gcc-2023-06-19, r=bjorn3 2023-06-22 02:11:08 +00:00
rustc_codegen_llvm Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk 2023-06-30 00:35:19 +00:00
rustc_codegen_ssa Rollup merge of #112946 - nnethercote:improve-cgu-naming-and-ordering, r=wesleywiser 2023-06-29 03:29:32 +09:00
rustc_const_eval remove FIXME and add test 2023-06-28 07:59:36 -04:00
rustc_data_structures Remove SmallStr. 2023-06-29 11:45:52 +10:00
rustc_driver fix spelling error 2023-06-05 16:01:09 +02:00
rustc_driver_impl Add a simple markdown parser for formatting rustc --explain 2023-07-03 16:04:18 -04:00
rustc_error_codes Implement custom diagnostic for ConstParamTy 2023-06-01 18:21:42 +00:00
rustc_error_messages Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
rustc_errors Add a simple markdown parser for formatting rustc --explain 2023-07-03 16:04:18 -04:00
rustc_expand Rollup merge of #111571 - jhpratt:proc-macro-span, r=m-ou-se 2023-06-28 18:28:46 +05:30
rustc_feature Rollup merge of #112670 - petrochenkov:typriv, r=eholk 2023-06-29 05:48:39 +02:00
rustc_fluent_macro Fix diagnostics with errors 2023-05-26 10:44:18 +00:00
rustc_fs_util Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
rustc_graphviz enable rust_2018_idioms for doctests 2023-05-07 00:12:29 +03:00
rustc_hir Add bidirectional where clauses on RPITIT synthesized GATs 2023-06-29 14:26:26 -03:00
rustc_hir_analysis Add bidirectional where clauses on RPITIT synthesized GATs 2023-06-29 14:26:26 -03:00
rustc_hir_pretty hir: Add Become expression kind 2023-06-26 08:56:32 +00:00
rustc_hir_typeck Rollup merge of #113084 - WaffleLapkin:less_map_or, r=Nilstrieb 2023-06-27 22:10:15 +02:00
rustc_incremental Applied nits 2023-06-11 22:45:04 -04:00
rustc_index Auto merge of #111925 - Manishearth:rollup-z6z6l2v, r=Manishearth 2023-05-25 00:33:43 +00:00
rustc_infer avoid using format!("{}", ..) 2023-06-27 22:12:29 +09:00
rustc_interface Auto merge of #112708 - flip1995:clippy-freezing-pc-with-ice, r=oli-obk 2023-06-28 09:40:07 +00:00
rustc_lexer Don't try to eat non-existent decimal digits. 2023-05-15 18:33:12 +10:00
rustc_lint Rollup merge of #112670 - petrochenkov:typriv, r=eholk 2023-06-29 05:48:39 +02:00
rustc_lint_defs Rollup merge of #112670 - petrochenkov:typriv, r=eholk 2023-06-29 05:48:39 +02:00
rustc_llvm Add SafeStack support to rustc 2023-05-26 15:18:54 -04:00
rustc_log Stabilize IsTerminal 2023-04-10 17:24:23 +09:00
rustc_macros Auto merge of #111269 - clubby789:validate-fluent-variables, r=davidtwco 2023-06-28 03:47:02 +00:00
rustc_metadata Auto merge of #98867 - cjgillot:metaloop, r=oli-obk 2023-06-28 16:16:27 +00:00
rustc_middle Rollup merge of #112670 - petrochenkov:typriv, r=eholk 2023-06-29 05:48:39 +02:00
rustc_mir_build remove cruft 2023-06-28 01:55:32 -04:00
rustc_mir_dataflow Export AnalysisResults trait in rustc_mir_dataflow 2023-06-27 11:35:32 +02:00
rustc_mir_transform Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk 2023-06-30 00:35:19 +00:00
rustc_monomorphize Tweak thread names for CGU processing. 2023-06-26 09:14:45 +10:00
rustc_parse Auto merge of #113105 - matthiaskrgr:rollup-rci0uym, r=matthiaskrgr 2023-06-27 21:31:47 +00:00
rustc_parse_format Fix typos in compiler 2023-04-10 22:02:52 +02:00
rustc_passes Auto merge of #111269 - clubby789:validate-fluent-variables, r=davidtwco 2023-06-28 03:47:02 +00:00
rustc_plugin_impl Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_privacy Rollup merge of #112670 - petrochenkov:typriv, r=eholk 2023-06-29 05:48:39 +02:00
rustc_query_impl Avoid calling queries during query stack printing 2023-06-27 16:12:07 +02:00
rustc_query_system Rollup merge of #112333 - Zoxc:try_collect_active_jobs-deadlock, r=cjgillot 2023-06-08 12:36:18 +02:00
rustc_resolve Rollup merge of #113084 - WaffleLapkin:less_map_or, r=Nilstrieb 2023-06-27 22:10:15 +02:00
rustc_serialize Fix the FileEncoder buffer size. 2023-05-15 08:59:11 +10:00
rustc_session Add a simple markdown parser for formatting rustc --explain 2023-07-03 16:04:18 -04:00
rustc_smir Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber 2023-06-19 17:53:33 -07:00
rustc_span Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk 2023-06-30 00:35:19 +00:00
rustc_symbol_mangling Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
rustc_target Rollup merge of #111326 - he32:netbsd-aarch64-be, r=oli-obk 2023-06-26 11:58:43 +02:00
rustc_trait_selection Auto merge of #113108 - compiler-errors:normalize-opaques-with-late-bound-vars-again, r=jackh726 2023-06-29 15:37:11 +00:00
rustc_traits Remove unnecessary DefineOpaqueTypes::Bubble from codegen 2023-06-27 21:36:15 +00:00
rustc_transmute Safe Transmute: Refactor error handling and Answer type 2023-06-12 16:56:21 -07:00
rustc_ty_utils Add bidirectional where clauses on RPITIT synthesized GATs 2023-06-29 14:26:26 -03:00
rustc_type_ir Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00