Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up rustdoc's main() #75124

Merged
merged 3 commits into from
Aug 5, 2020
Merged

Commits on Aug 5, 2020

  1. Avoid an unnecessary thread creation at rustdoc startup.

    rustdoc's `main()` immediately spawns a thread, M, with a large stack
    (16MiB or 32MiB) on which it runs `main_args()`. `main_args()` does a
    small amount of options processing and then calls
    `setup_callbacks_and_run_in_default_thread_pool_with_globals()`, which
    spawns it own thread, and M is not used further.
    
    So, thread M seems unnecessary. However, it does serve a purpose: if the
    options processing in `main_args()` panics, that panic is caught when M
    is joined. So M can't simply be removed.
    
    However, `main_options()`, which is called by `main_args()`, has a
    `catch_fatal_errors()` call within it. We can move that call to `main()`
    and change it to the very similar `catch_with_exit_code()`. With that in
    place, M can be removed, and panics from options processing will still
    be caught appropriately.
    
    Even better, this makes rustdoc's `main()` match rustc's `main()`, which
    also uses `catch_with_exit_code()`.
    
    (Also note that the use of a 16MiB/32MiB stack was eliminated from rustc
    in rust-lang#55617.)
    nnethercote committed Aug 5, 2020
    Configuration menu
    Copy the full SHA
    5301407 View commit details
    Browse the repository at this point in the history
  2. Remove setup_callbacks_and_run_in_default_thread_pool_with_globals().

    It's a very thin wrapper around
    `setup_callbacks_and_run_in_thread_pool_with_globals()` and it has a
    single call site.
    nnethercote committed Aug 5, 2020
    Configuration menu
    Copy the full SHA
    af4e3e0 View commit details
    Browse the repository at this point in the history
  3. Be smarter about error handling in run().

    `run()` returns `Result<(), String>`. But on failure it always returns
    an empty string, and then `wrap_return()` treats an empty string
    specially, by not reporting the error.
    
    It turns out we already have the `ErrorReported` type for this sort of
    behaviour. This commit changes `run()` to use it.
    nnethercote committed Aug 5, 2020
    Configuration menu
    Copy the full SHA
    5f8a112 View commit details
    Browse the repository at this point in the history