mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-11-03 22:49:17 +00:00 
			
		
		
		
	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.
		
	
			
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TOML
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TOML
		
	
	
	
	
	
[package]
 | 
						|
name = "rustc_errors"
 | 
						|
version = "0.0.0"
 | 
						|
edition = "2021"
 | 
						|
 | 
						|
[lib]
 | 
						|
 | 
						|
[dependencies]
 | 
						|
tracing = "0.1"
 | 
						|
rustc_ast = { path = "../rustc_ast" }
 | 
						|
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
 | 
						|
rustc_error_messages = { path = "../rustc_error_messages" }
 | 
						|
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
 | 
						|
rustc_serialize = { path = "../rustc_serialize" }
 | 
						|
rustc_span = { path = "../rustc_span" }
 | 
						|
rustc_macros = { path = "../rustc_macros" }
 | 
						|
rustc_data_structures = { path = "../rustc_data_structures" }
 | 
						|
rustc_target = { path = "../rustc_target" }
 | 
						|
rustc_hir = { path = "../rustc_hir" }
 | 
						|
rustc_lint_defs = { path = "../rustc_lint_defs" }
 | 
						|
rustc_type_ir = { path = "../rustc_type_ir" }
 | 
						|
unicode-width = "0.1.4"
 | 
						|
termcolor = "1.2.0"
 | 
						|
annotate-snippets = "0.9"
 | 
						|
termize = "0.1.1"
 | 
						|
serde = { version = "1.0.125", features = [ "derive" ] }
 | 
						|
serde_json = "1.0.59"
 | 
						|
 | 
						|
[target.'cfg(windows)'.dependencies.windows]
 | 
						|
version = "0.48.0"
 | 
						|
features = [
 | 
						|
    "Win32_Foundation",
 | 
						|
    "Win32_Security",
 | 
						|
    "Win32_System_Threading",
 | 
						|
]
 | 
						|
 | 
						|
[features]
 | 
						|
rustc_use_parallel_compiler = ['rustc_error_messages/rustc_use_parallel_compiler']
 |