From d479cc6588e4d7ecd5c095503169e37b89dd4fcf Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Fri, 1 Nov 2024 07:53:03 -0400 Subject: [PATCH] Add `bounds` and `convert` deprecation notices --- examples/tests/associated_type.rs | 3 +++ examples/tests/conversion.rs | 3 +++ macro/src/lib.rs | 19 +++++++++++++++++++ test-fuzz/src/lib.rs | 13 +++++++++++++ 4 files changed, 38 insertions(+) diff --git a/examples/tests/associated_type.rs b/examples/tests/associated_type.rs index 7805cb0b..e0549f11 100644 --- a/examples/tests/associated_type.rs +++ b/examples/tests/associated_type.rs @@ -1,3 +1,6 @@ +#![cfg_attr(dylint_lib = "general", allow(crate_wide_allow))] +#![allow(deprecated)] + // smoelius: Associated types are considered a legitimate reason to put a bound on a struct // parameter. See: // * https://github.com/rust-lang/rust-clippy/issues/1689 diff --git a/examples/tests/conversion.rs b/examples/tests/conversion.rs index 75c962ca..2fcbb718 100644 --- a/examples/tests/conversion.rs +++ b/examples/tests/conversion.rs @@ -1,3 +1,6 @@ +#![cfg_attr(dylint_lib = "general", allow(crate_wide_allow))] +#![allow(deprecated)] + mod path { use std::path::Path; use test_fuzz::leak; diff --git a/macro/src/lib.rs b/macro/src/lib.rs index 59676d2f..1bc18491 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -713,6 +713,21 @@ fn map_method_or_fn( }, ) }; + // smoelius: https://stackoverflow.com/a/77267752 + let bounds_deprecation_notice = if opts.bounds.is_none() { + quote! {} + } else { + quote! { + const _: () = test_fuzz::bounds(); + } + }; + let convert_deprecation_notice = if opts.convert.is_empty() { + quote! {} + } else { + quote! { + const _: () = test_fuzz::convert(); + } + }; ( parse_quote! { #(#attrs)* #vis #defaultness #sig { @@ -730,6 +745,10 @@ fn map_method_or_fn( mod #mod_ident { use super::*; + #bounds_deprecation_notice + + #convert_deprecation_notice + #struct_args #mod_items diff --git a/test-fuzz/src/lib.rs b/test-fuzz/src/lib.rs index b80dd3bc..f3277938 100644 --- a/test-fuzz/src/lib.rs +++ b/test-fuzz/src/lib.rs @@ -20,3 +20,16 @@ pub use utils::{deserialize_ref, deserialize_ref_mut, serialize_ref, serialize_r mod convert; pub use convert::{FromRef, Into}; + +// smoelius: https://stackoverflow.com/a/77267752 +#[deprecated = r#"`bounds` will be removed in a future version of test-fuzz. +The same functionality can be achieved with `#[serde(bound = "T: MyTrait")]`. +See: https://serde.rs/field-attrs.html"#] +#[doc(hidden)] +pub const fn bounds() {} + +#[deprecated = r#"`convert` will be removed in a future version of test-fuzz. +The same functionality can be achieved with `#[serde(serialize_with = "path")]` and `#[serde(deserialize_with = "path")]`. +See: https://serde.rs/field-attrs.html"#] +#[doc(hidden)] +pub const fn convert() {}