Skip to content

Commit 738cfee

Browse files
committed
Get rid of the unused_unsafe warning on old versions of Rust.
1 parent 996b1e9 commit 738cfee

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ fn main() {
2727
{
2828
println!("cargo:rustc-cfg=nightly");
2929
}
30+
31+
let rustc_version = rustc_version::version().expect("failed to detect rustc version");
32+
if rustc_version.major == 1 && rustc_version.minor <= 64 {
33+
// Old versions of Rust complain when you have an `unsafe fn` and you use `unsafe {}` inside,
34+
// so for those we want to apply the `#[allow(unused_unsafe)]` attribute to get rid of that warning.
35+
println!("cargo:rustc-cfg=allow_unused_unsafe");
36+
}
3037
}
3138

3239
// Deterministic cfg(curve25519_dalek_bits) when this is not explicitly set.

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)]
2121
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg, doc_cfg_hide))]
2222
#![cfg_attr(docsrs, doc(cfg_hide(docsrs)))]
23+
#![cfg_attr(allow_unused_unsafe, allow(unused_unsafe))]
2324
//------------------------------------------------------------------------
2425
// Documentation:
2526
//------------------------------------------------------------------------

0 commit comments

Comments
 (0)