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

rustdoc: Use diagnostics for error when including sources #82993

Merged
merged 1 commit into from
Mar 27, 2021

Commits on Mar 24, 2021

  1. rustdoc: Use diagnostics for error when including sources

    This error probably almost never happens, but we should still use the
    diagnostic infrastructure. My guess is that the error was added back
    before rustdoc used the rustc diagnostic infrastructure (it was all
    `println!` and `eprintln!` back then!) and since it likely rarely occurs
    and this code doesn't change that much, no one thought to transition it
    to using diagnostics.
    
    Note that the old error was actually a warning (it didn't stop the rest
    of doc building). It seems very unlikely that this would fail without
    the rest of the doc build failing, so it makes more sense for it to be a
    hard error.
    
    The error looks like this:
    
        error: failed to render source code for `src/test/rustdoc/smart-punct.rs`: "bar": foo
          --> src/test/rustdoc/smart-punct.rs:3:1
           |
        3  | / #![crate_name = "foo"]
        4  | |
        5  | | //! This is the "start" of the 'document'! How'd you know that "it's" ...
        6  | | //!
        ...  |
        22 | | //! I say "don't smart-punct me -- please!"
        23 | | //! ```
           | |_______^
    
    I wasn't sure how to trigger the error, so to create that message I
    temporarily made rustdoc always emit it. That's also why it says "bar"
    and "foo" instead of a real error message.
    
    Note that the span of the diagnostic starts at line 3 because line 1 of
    that file is a (non-doc) comment and line 2 is a blank line.
    camelid committed Mar 24, 2021
    Configuration menu
    Copy the full SHA
    3d8ce0a View commit details
    Browse the repository at this point in the history