Skip to content

Commit 56a2961

Browse files
authored
Enable lints in Cargo.toml (#791)
1 parent 4f596a9 commit 56a2961

6 files changed

Lines changed: 32 additions & 23 deletions

File tree

Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@ check-cfg = [
102102
'cfg(target_os, values("cygwin"))', # TODO(MSRV 1.86): Remove this.
103103
]
104104

105+
[lints.rust]
106+
unused_lifetimes = "warn"
107+
missing_docs = "warn"
108+
109+
[lints.clippy]
110+
cast_lossless = "warn"
111+
cast_possible_truncation = "warn"
112+
cast_possible_wrap = "warn"
113+
cast_precision_loss = "warn"
114+
cast_ptr_alignment = "warn"
115+
cast_sign_loss = "warn"
116+
char_lit_as_u8 = "warn"
117+
checked_conversions = "warn"
118+
fn_to_numeric_cast = "warn"
119+
fn_to_numeric_cast_with_truncation = "warn"
120+
ptr_as_ptr = "warn"
121+
unnecessary_cast = "warn"
122+
useless_conversion = "warn"
123+
105124
# workaround for https://github.com/cross-rs/cross/issues/1345
106125
[package.metadata.cross.target.x86_64-unknown-netbsd]
107126
pre-build = [

benches/buffer.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Basic benchmarks
12
#![feature(test, maybe_uninit_uninit_array_transpose)]
23
extern crate test;
34

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

2526
#[bench]
26-
pub fn bench_u32(b: &mut test::Bencher) {
27+
fn bench_u32(b: &mut test::Bencher) {
2728
#[inline(never)]
2829
fn inner() -> u32 {
2930
getrandom::u32().unwrap()
3031
}
3132
b.bytes = 4;
3233
b.iter(inner);
3334
}
35+
3436
#[bench]
35-
pub fn bench_u32_via_fill(b: &mut test::Bencher) {
37+
fn bench_u32_via_fill(b: &mut test::Bencher) {
3638
#[inline(never)]
3739
fn inner() -> u32 {
3840
let mut res = MaybeUninit::<u32>::uninit();
@@ -46,7 +48,7 @@ pub fn bench_u32_via_fill(b: &mut test::Bencher) {
4648
}
4749

4850
#[bench]
49-
pub fn bench_u64(b: &mut test::Bencher) {
51+
fn bench_u64(b: &mut test::Bencher) {
5052
#[inline(never)]
5153
fn inner() -> u64 {
5254
getrandom::u64().unwrap()
@@ -56,7 +58,7 @@ pub fn bench_u64(b: &mut test::Bencher) {
5658
}
5759

5860
#[bench]
59-
pub fn bench_u64_via_fill(b: &mut test::Bencher) {
61+
fn bench_u64_via_fill(b: &mut test::Bencher) {
6062
#[inline(never)]
6163
fn inner() -> u64 {
6264
let mut res = MaybeUninit::<u64>::uninit();
@@ -78,9 +80,9 @@ pub fn bench_u64_via_fill(b: &mut test::Bencher) {
7880
// cargo asm --bench buffer --release buffer::p384::bench_getrandom::inner
7981
macro_rules! bench {
8082
( $name:ident, $size:expr ) => {
81-
pub mod $name {
83+
mod $name {
8284
#[bench]
83-
pub fn bench_fill(b: &mut test::Bencher) {
85+
fn bench_fill(b: &mut test::Bencher) {
8486
#[inline(never)]
8587
fn inner() {
8688
super::bench_fill::<{ $size }>()
@@ -90,7 +92,7 @@ macro_rules! bench {
9092
b.iter(inner);
9193
}
9294
#[bench]
93-
pub fn bench_fill_uninit(b: &mut test::Bencher) {
95+
fn bench_fill_uninit(b: &mut test::Bencher) {
9496
#[inline(never)]
9597
fn inner() {
9698
super::bench_fill_uninit::<{ $size }>()

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Build script for memory sanitization support
2+
13
fn main() {
24
// Automatically detect cfg(sanitize = "memory") even if cfg(sanitize) isn't
35
// supported. Build scripts get cfg() info, even if the cfg is unstable.

src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,8 @@
88
html_favicon_url = "https://www.rust-lang.org/favicon.ico"
99
)]
1010
#![doc = include_str!("../README.md")]
11-
#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)]
1211
#![cfg_attr(docsrs, feature(doc_cfg))]
1312
#![cfg_attr(getrandom_backend = "efi_rng", feature(uefi_std))]
14-
#![deny(
15-
clippy::cast_lossless,
16-
clippy::cast_possible_truncation,
17-
clippy::cast_possible_wrap,
18-
clippy::cast_precision_loss,
19-
clippy::cast_ptr_alignment,
20-
clippy::cast_sign_loss,
21-
clippy::char_lit_as_u8,
22-
clippy::checked_conversions,
23-
clippy::fn_to_numeric_cast,
24-
clippy::fn_to_numeric_cast_with_truncation,
25-
clippy::ptr_as_ptr,
26-
clippy::unnecessary_cast,
27-
clippy::useless_conversion
28-
)]
2913

3014
#[macro_use]
3115
extern crate cfg_if;

tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Main `getrandom` tests
12
use core::mem::MaybeUninit;
23
use getrandom::{fill, fill_uninit};
34

tests/sys_rng.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Tests for `SysRng`
12
#![cfg(feature = "sys_rng")]
23

34
use getrandom::SysRng;

0 commit comments

Comments
 (0)