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

Make Rustdoc exit with correct error code when scraping examples from invalid files #99976

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

willcrichton
Copy link
Contributor

This PR fixes a small issue with the new Rustdoc scrape-examples feature. If a file that is being scraped has a type error, then currently that error is printed out, but the rustdoc process exits as if it succeeded. This is a problem for Cargo, which needs to track whether scraping succeeded (see rust-lang/cargo#10343).

This PR fixes the issue by checking whether an error is emitted, and aborting if so.

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 31, 2022
@rust-highfive
Copy link
Collaborator

r? @jsha

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 31, 2022
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a UI test? r=me with that done

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2022
@willcrichton
Copy link
Contributor Author

@jyn514 done!

| ^^^^^^^^^^^^ could not resolve path `INVALID_FUNC`
|
= note: this error was originally ignored because you are running `rustdoc`
= note: try running again with `rustc` or `cargo check` and you may get a more detailed error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol so that's where this error will show up in practice, I mostly just added it for completeness

yeah this seems ok; it points to the right place and gives you an idea of what's going wrong. The only thing to improve is that rustdoc doesn't need to tell the resolver to ignore errors in the first place when scraping examples, but that will be kind of annoying to fix for very marginal benefit.

@jyn514
Copy link
Member

jyn514 commented Aug 1, 2022

@bors r+ rollup

Thanks!

@bors
Copy link
Contributor

bors commented Aug 1, 2022

📌 Commit a93feaf has been approved by jyn514

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 1, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 1, 2022
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#99340 (Fix ICE in Definitions::create_def)
 - rust-lang#99629 (Improve `cannot move out of` error message)
 - rust-lang#99864 (bootstrap: don't emit warn about duplicated deps with same/different features if some of sets actually empty)
 - rust-lang#99911 (Remove some uses of `guess_head_span`)
 - rust-lang#99976 (Make Rustdoc exit with correct error code when scraping examples from invalid files)
 - rust-lang#100003 (Improve size assertions.)
 - rust-lang#100012 (Avoid `Ty` to `String` conversions)
 - rust-lang#100020 (better error when python is not found in x - issue rust-lang#99648)

Failed merges:

 - rust-lang#99994 (Replace `guess_head_span` with `opt_span`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1fa02dd into rust-lang:master Aug 1, 2022
@rustbot rustbot added this to the 1.64.0 milestone Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants