From 1ab6d6888e8ebf0db1e1aca6819e33ef7bd08d9c Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Mon, 30 Oct 2023 08:04:56 -0700 Subject: [PATCH] Deny strict provenance lints during testing (#572) When testing in CI on the nightly toolchain, deny the `fuzzy_provenance_casts` and `lossy_provenance_casts` lints. --- src/lib.rs | 4 ++++ src/util.rs | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 56b4cf46be..c42584d7dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -167,6 +167,10 @@ unused_qualifications, variant_size_differences )] +#![cfg_attr( + __INTERNAL_USE_ONLY_NIGHLTY_FEATURES_IN_TESTS, + deny(fuzzy_provenance_casts, lossy_provenance_casts) +)] #![deny( clippy::all, clippy::alloc_instead_of_core, diff --git a/src/util.rs b/src/util.rs index 82e201c601..bcbb287513 100644 --- a/src/util.rs +++ b/src/util.rs @@ -464,10 +464,11 @@ impl<'a, T: ?Sized> AsAddress for &'a mut T { impl AsAddress for *const T { #[inline(always)] fn addr(self) -> usize { - // TODO(https://github.com/rust-lang/rust/issues/95228): Use `.addr()` - // instead of `as usize` once it's stable, and get rid of this `allow`. - // Currently, `as usize` is the only way to accomplish this. + // TODO(#181), TODO(https://github.com/rust-lang/rust/issues/95228): Use + // `.addr()` instead of `as usize` once it's stable, and get rid of this + // `allow`. Currently, `as usize` is the only way to accomplish this. #[allow(clippy::as_conversions)] + #[cfg_attr(__INTERNAL_USE_ONLY_NIGHLTY_FEATURES_IN_TESTS, allow(lossy_provenance_casts))] return self.cast::<()>() as usize; } }