Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@ check-cfg = [
'cfg(target_os, values("cygwin"))', # TODO(MSRV 1.86): Remove this.
]

[lints.rust]
unused_lifetimes = "warn"
missing_docs = "warn"

[lints.clippy]
cast_lossless = "warn"
cast_possible_truncation = "warn"
cast_possible_wrap = "warn"
cast_precision_loss = "warn"
cast_ptr_alignment = "warn"
cast_sign_loss = "warn"
char_lit_as_u8 = "warn"
checked_conversions = "warn"
fn_to_numeric_cast = "warn"
fn_to_numeric_cast_with_truncation = "warn"
ptr_as_ptr = "warn"
unnecessary_cast = "warn"
useless_conversion = "warn"

# workaround for https://github.com/cross-rs/cross/issues/1345
[package.metadata.cross.target.x86_64-unknown-netbsd]
pre-build = [
Expand Down
16 changes: 9 additions & 7 deletions benches/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Basic benchmarks
#![feature(test, maybe_uninit_uninit_array_transpose)]
extern crate test;

Expand All @@ -23,16 +24,17 @@ fn bench_fill_uninit<const N: usize>() {
}

#[bench]
pub fn bench_u32(b: &mut test::Bencher) {
fn bench_u32(b: &mut test::Bencher) {
#[inline(never)]
fn inner() -> u32 {
getrandom::u32().unwrap()
}
b.bytes = 4;
b.iter(inner);
}

#[bench]
pub fn bench_u32_via_fill(b: &mut test::Bencher) {
fn bench_u32_via_fill(b: &mut test::Bencher) {
#[inline(never)]
fn inner() -> u32 {
let mut res = MaybeUninit::<u32>::uninit();
Expand All @@ -46,7 +48,7 @@ pub fn bench_u32_via_fill(b: &mut test::Bencher) {
}

#[bench]
pub fn bench_u64(b: &mut test::Bencher) {
fn bench_u64(b: &mut test::Bencher) {
#[inline(never)]
fn inner() -> u64 {
getrandom::u64().unwrap()
Expand All @@ -56,7 +58,7 @@ pub fn bench_u64(b: &mut test::Bencher) {
}

#[bench]
pub fn bench_u64_via_fill(b: &mut test::Bencher) {
fn bench_u64_via_fill(b: &mut test::Bencher) {
#[inline(never)]
fn inner() -> u64 {
let mut res = MaybeUninit::<u64>::uninit();
Expand All @@ -78,9 +80,9 @@ pub fn bench_u64_via_fill(b: &mut test::Bencher) {
// cargo asm --bench buffer --release buffer::p384::bench_getrandom::inner
macro_rules! bench {
( $name:ident, $size:expr ) => {
pub mod $name {
mod $name {
#[bench]
pub fn bench_fill(b: &mut test::Bencher) {
fn bench_fill(b: &mut test::Bencher) {
#[inline(never)]
fn inner() {
super::bench_fill::<{ $size }>()
Expand All @@ -90,7 +92,7 @@ macro_rules! bench {
b.iter(inner);
}
#[bench]
pub fn bench_fill_uninit(b: &mut test::Bencher) {
fn bench_fill_uninit(b: &mut test::Bencher) {
#[inline(never)]
fn inner() {
super::bench_fill_uninit::<{ $size }>()
Expand Down
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Build script for memory sanitization support

fn main() {
// Automatically detect cfg(sanitize = "memory") even if cfg(sanitize) isn't
// supported. Build scripts get cfg() info, even if the cfg is unstable.
Expand Down
16 changes: 0 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,8 @@
html_favicon_url = "https://www.rust-lang.org/favicon.ico"
)]
#![doc = include_str!("../README.md")]
#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(getrandom_backend = "efi_rng", feature(uefi_std))]
#![deny(
clippy::cast_lossless,
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_precision_loss,
clippy::cast_ptr_alignment,
clippy::cast_sign_loss,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::fn_to_numeric_cast,
clippy::fn_to_numeric_cast_with_truncation,
clippy::ptr_as_ptr,
clippy::unnecessary_cast,
clippy::useless_conversion
)]

#[macro_use]
extern crate cfg_if;
Expand Down
1 change: 1 addition & 0 deletions tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Main `getrandom` tests
use core::mem::MaybeUninit;
use getrandom::{fill, fill_uninit};

Expand Down
1 change: 1 addition & 0 deletions tests/sys_rng.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Tests for `SysRng`
#![cfg(feature = "sys_rng")]

use getrandom::SysRng;
Expand Down