diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-01 16:49:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-01 16:49:32 +0200 |
| commit | 1fa02dd3e958dad25d667fab2037d7a6d4ab3b37 (patch) | |
| tree | df97d68e712fafcca0e650224b70ec5a000d1ffe /src/test/rustdoc-ui | |
| parent | 8db3d7cfb635356f16fd71dd8e873093799690da (diff) | |
| parent | a93feaf6e12bf6a14f65c7ab21c6262796315626 (diff) | |
| download | rust-1fa02dd3e958dad25d667fab2037d7a6d4ab3b37.tar.gz rust-1fa02dd3e958dad25d667fab2037d7a6d4ab3b37.zip | |
Rollup merge of #99976 - willcrichton:example-analyzer, r=jyn514
Make Rustdoc exit with correct error code when scraping examples from invalid files 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.
Diffstat (limited to 'src/test/rustdoc-ui')
| -rw-r--r-- | src/test/rustdoc-ui/scrape-examples-fail-if-type-error.rs | 7 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/scrape-examples-fail-if-type-error.stderr | 14 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/rustdoc-ui/scrape-examples-fail-if-type-error.rs b/src/test/rustdoc-ui/scrape-examples-fail-if-type-error.rs new file mode 100644 index 00000000000..8f4fde96d7e --- /dev/null +++ b/src/test/rustdoc-ui/scrape-examples-fail-if-type-error.rs @@ -0,0 +1,7 @@ +// check-fail +// compile-flags: -Z unstable-options --scrape-examples-output-path {{build-base}}/t.calls --scrape-examples-target-crate foobar + +pub fn foo() { + INVALID_FUNC(); + //~^ ERROR could not resolve path +} diff --git a/src/test/rustdoc-ui/scrape-examples-fail-if-type-error.stderr b/src/test/rustdoc-ui/scrape-examples-fail-if-type-error.stderr new file mode 100644 index 00000000000..750aa320719 --- /dev/null +++ b/src/test/rustdoc-ui/scrape-examples-fail-if-type-error.stderr @@ -0,0 +1,14 @@ +error[E0433]: failed to resolve: could not resolve path `INVALID_FUNC` + --> $DIR/scrape-examples-fail-if-type-error.rs:5:3 + | +LL | INVALID_FUNC(); + | ^^^^^^^^^^^^ 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 + +error: Compilation failed, aborting rustdoc + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. |
