docs: clarify backtrace capture behavior in README - #457
Open
eastspire wants to merge 1 commit into
Open
Conversation
The previous wording stated that a backtrace is captured and printed with the error "if the underlying error type does not already provide its own", implying that anyhow always checks the underlying error. In fact, that check is only performed on nightly Rust when the unstable `error_generic_member_access` feature is enabled (see src/backtrace.rs). On stable, anyhow unconditionally captures a backtrace. Reword the README and the corresponding crate-level rustdoc to describe the stable behavior first, and explicitly call out the nightly-only opt-out for errors that already provide a backtrace. Closes dtolnay#409
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #409
Summary
The README and the corresponding crate-level rustdoc currently state that
a backtrace is captured and printed with the error "if the underlying
error type does not already provide its own". This wording implies that
anyhow always checks the underlying error, but in fact that check is
only performed on nightly Rust when the unstable
error_generic_member_accessfeature is enabled (seesrc/backtrace.rs). On stable, anyhow unconditionally captures abacktrace.
This rewording:
printed with the error"), removing the misleading conditional.
error_generic_member_access, anyhow additionally detects when theunderlying error type already provides a backtrace and avoids
capturing a second one.
Changes
Both files contain essentially the same paragraph (the rustdoc is
mirrored from the README), so they are updated together to keep them
in sync.
Test plan
cargo buildcargo test(including 26 doc-tests, which exercise theupdated rustdoc paragraph)
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warnings