From 657e7cb08d6146cce6c7d81c044bdaa69f13869b Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Thu, 20 Apr 2023 09:30:55 -0400 Subject: [PATCH 1/2] time: hard deprecate Time::try_from. --- src/time.rs | 2 +- tests/integration.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/time.rs b/src/time.rs index a6c0c206..17569b19 100644 --- a/src/time.rs +++ b/src/time.rs @@ -25,7 +25,7 @@ pub struct Time(u64); impl Time { /// Deprecated. Use `TryFrom::try_from`. #[cfg(feature = "std")] - // Soft deprecation. #[deprecated(note = "Use TryFrom::try_from")] + #[deprecated(note = "Use TryFrom::try_from")] pub fn try_from(time: std::time::SystemTime) -> Result { core::convert::TryFrom::try_from(time) } diff --git a/tests/integration.rs b/tests/integration.rs index 713cef20..cb9d0e6e 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -204,5 +204,11 @@ fn read_ee_with_large_pos_serial() { #[cfg(feature = "std")] #[test] fn time_constructor() { + // TODO(XXX): Remove when deprecated Time::try_from fn is removed. + #[allow(deprecated)] let _ = webpki::Time::try_from(std::time::SystemTime::now()).unwrap(); + + let _ = + >::try_from(std::time::SystemTime::now()) + .unwrap(); } From 0380181094b52becb06fe066bcf969f2b66a4650 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Thu, 20 Apr 2023 09:40:41 -0400 Subject: [PATCH 2/2] subject_name: deprecate From for DnsName. As mentioned in the comment we can't outright `#[deprecate]` this one because it's a trait impl. Instead, promote the deprecation note to the rustdoc comment, add a TODO to remove it outright, and switch our own tests to call `to_owned()` directly in preparation of an eventual removal. --- src/subject_name/dns_name.rs | 5 ++++- tests/name_tests.rs | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/subject_name/dns_name.rs b/src/subject_name/dns_name.rs index 54e3c979..13bb462e 100644 --- a/src/subject_name/dns_name.rs +++ b/src/subject_name/dns_name.rs @@ -55,9 +55,12 @@ impl AsRef for DnsName { } /// Requires the `alloc` feature. -// Deprecated +/// Deprecated. #[cfg(feature = "alloc")] impl From> for DnsName { + // TODO(XXX): Remove this trait impl in the next release. We can't mark it as + // hard deprecated as this isn't supported and produces a + // 'useless_deprecated' warning. fn from(dns_name: DnsNameRef) -> Self { dns_name.to_owned() } diff --git a/tests/name_tests.rs b/tests/name_tests.rs index cde88acf..62e9a092 100644 --- a/tests/name_tests.rs +++ b/tests/name_tests.rs @@ -41,6 +41,7 @@ fn test_dns_name_traits() { let a_ref = DnsNameRef::try_from_ascii(b"example.com").unwrap(); // `From` + // TODO(XXX): Remove when deprecated From for DnsName trait is removed. let a: DnsName = DnsName::from(a_ref); // `Clone`, `Debug`, `PartialEq`. @@ -52,16 +53,22 @@ fn test_dns_name_traits() { // PartialEq is case-insensitive assert_eq!( a, - DnsName::from(DnsNameRef::try_from_ascii(b"Example.Com").unwrap()) + DnsNameRef::try_from_ascii(b"Example.Com") + .unwrap() + .to_owned() ); // PartialEq isn't completely wrong. assert_ne!( a, - DnsName::from(DnsNameRef::try_from_ascii(b"fxample.com").unwrap()) + DnsNameRef::try_from_ascii(b"fxample.com") + .unwrap() + .to_owned() ); assert_ne!( a, - DnsName::from(DnsNameRef::try_from_ascii(b"example.co").unwrap()) + DnsNameRef::try_from_ascii(b"example.co") + .unwrap() + .to_owned() ); }