Skip to content

Commit

Permalink
Rollup merge of #108416 - pat-nel87:Issue-107957-black_box_docs, r=jy…
Browse files Browse the repository at this point in the history
…n514

black_box doc corrections for clarification - Issue #107957

Made a complete pass through the docs to help resolve #107957

No code changes, just documentation

`@rustbot` label +T-libs-api -T-libs
  • Loading branch information
jyn514 committed Apr 26, 2023
2 parents adaac6b + af489af commit ab7e01e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,14 @@ pub fn spin_loop() {
/// Note however, that `black_box` is only (and can only be) provided on a "best-effort" basis. The
/// extent to which it can block optimisations may vary depending upon the platform and code-gen
/// backend used. Programs cannot rely on `black_box` for *correctness*, beyond it behaving as the
/// identity function.
/// identity function. As such, it **must not be relied upon to control critical program behavior.**
/// This _immediately_ precludes any direct use of this function for cryptographic or security
/// purposes.
///
/// [`std::convert::identity`]: crate::convert::identity
///
/// # When is this useful?
///
/// First and foremost: `black_box` does _not_ guarantee any exact behavior and, in some cases, may
/// do nothing at all. As such, it **must not be relied upon to control critical program behavior.**
/// This _immediately_ precludes any direct use of this function for cryptographic or security
/// purposes.
///
/// While not suitable in those mission-critical cases, `black_box`'s functionality can generally be
/// relied upon for benchmarking, and should be used there. It will try to ensure that the
/// compiler doesn't optimize away part of the intended test code based on context. For
Expand Down

0 comments on commit ab7e01e

Please sign in to comment.