Skip to content

Commit

Permalink
Add a note to library authors regarding cargo::error
Browse files Browse the repository at this point in the history
There was a concern raised about potential use of `cargo::error` by
libraries, which could make it difficult for build script authors to
decide what is an error.
rust-lang#10159 (comment)
  • Loading branch information
ehuss committed Oct 29, 2024
1 parent 9ce30a6 commit deb028f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/doc/src/reference/build-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ to set the shared library version or the runtime-path.
The `error` instruction tells Cargo to display an error after the build script
has finished running, and then fail the build.

> Note: Build script libraries should carefully consider if they want to
> use `cargo::error` versus returning a `Result`. It may be better to return
> a `Result`, and allow the caller to decide if the error is fatal or not.
> The caller can then decide whether or not to display the `Err` variant
> using `cargo::error`.
> **MSRV:** Respected as of 1.82
### `cargo::warning=MESSAGE` {#cargo-warning}
Expand Down

0 comments on commit deb028f

Please sign in to comment.