rust/compiler/rustc_driver_impl
Nicholas Nethercote 525e1919f7 Rewrite show_md_content_with_pager.
I think the control flow in this function is complicated and confusing,
largely due to the use of two booleans `print_formatted` and
`fallback_to_println` that are set in multiple places and then used to
guide proceedings.

As well as hurting readability, this leads to at least one bug: if the
`write_termcolor_buf` call fails and the pager also fails, the function
will try to print color output to stdout, but that output will be empty
because `write_termcolor_buf` failed. I.e. the `if fallback_to_println`
body fails to check `print_formatted`.

This commit rewrites the function to be neater and more Rust-y, e.g. by
putting the result of `write_termcolor_buf` into an `Option` so it can
only be used on success, and by using `?` more. It also changes
terminology a little, using "pretty" to mean "formatted and colorized".
The result is a little shorter, more readable, and less buggy.
2024-11-21 08:42:01 +11:00
..
src Rewrite show_md_content_with_pager. 2024-11-21 08:42:01 +11:00
Cargo.toml Auto merge of #132282 - Noratrieb:it-is-the-end-of-serial, r=cjgillot 2024-11-12 15:14:56 +00:00
messages.ftl Add a footer in FileEncoder and check for it in MemDecoder 2024-05-21 20:12:29 -04:00
README.md Update out-dated link 2024-10-06 18:08:28 +08:00

The driver crate is effectively the "main" function for the rust compiler. It orchestrates the compilation process and "knits together" the code from the other crates within rustc. This crate itself does not contain any of the "main logic" of the compiler (though it does have some code related to pretty printing or other minor compiler options).

For more information about how the driver works, see the rustc dev guide.