build: emit rustc-check-cfg for bench, read_buf

Fixes warnings generated with nightly when generating cargo docs of the
form:

```
error: unexpected `cfg` condition name: `bench`
   --> rustls/src/lib.rs:305:31
    |
305 | #![cfg_attr(not(any(read_buf, bench)), forbid(unstable_features))]
    |                               ^^^^^
    |
    = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(bench)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
```

We also need to apply this suggestion for `read_buf`, because of
a workaround documented for another upstream rust issue.

Note, because our MSRV is 1.63 we have to add the new `build.rs`
directives with the prefix `cargo:` instead of `cargo::` as described in
the warning output, or we get a new error of the form:

```
error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but the minimum supported Rust version of `rustls v0.23.5 (/home/daniel/Code/Rust/rustls/rustls)` is 1.63.
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script for more information about build script outputs.
```
This commit is contained in:
Daniel McCarney 2024-05-06 09:02:39 -04:00
parent 1265e55111
commit 69b5d2374e
1 changed files with 2 additions and 0 deletions

View File

@ -9,5 +9,7 @@ fn main() {}
#[cfg(feature = "read_buf")]
#[rustversion::nightly]
fn main() {
println!("cargo:rustc-check-cfg=cfg(bench)");
println!("cargo:rustc-check-cfg=cfg(read_buf)");
println!("cargo:rustc-cfg=read_buf");
}