Repository: oxidecomputer/typify
Pull request #826 (2025-05-15 16:24:21)

remove some dead code that displeases more recent rust versions


Patch:
diff --git a/typify-impl/src/convert.rs b/typify-impl/src/convert.rs
index 6e877d7..b92f078 100644
--- a/typify-impl/src/convert.rs
+++ b/typify-impl/src/convert.rs
@@ -2067,8 +2067,7 @@ mod tests {
     use serde_json::json;
 
     use crate::{
-        test_util::validate_output, validate_builtin, Error, Name, TypeSpace, TypeSpaceImpl,
-        TypeSpaceSettings,
+        test_util::validate_output, Error, Name, TypeSpace, TypeSpaceImpl, TypeSpaceSettings,
     };
 
     #[track_caller]
@@ -2177,13 +2176,6 @@ mod tests {
         validate_output::<Bar>();
     }
 
-    // TODO we can turn this on once we generate proper sets.
-    #[ignore]
-    #[test]
-    fn test_set() {
-        validate_builtin!(std::collections::BTreeSet<u32>);
-    }
-
     #[test]
     fn test_low_default() {
         let schema = SchemaObject {
diff --git a/typify-impl/src/lib.rs b/typify-impl/src/lib.rs
index 93f91dc..0f5f490 100644
--- a/typify-impl/src/lib.rs
+++ b/typify-impl/src/lib.rs
@@ -1176,7 +1176,7 @@ impl<'a> TypeStruct<'a> {
     }
 
     /// Get all information about each struct property.
-    pub fn properties_info(&'a self) -> impl Iterator<Item = TypeStructPropInfo> {
+    pub fn properties_info(&'a self) -> impl Iterator<Item = TypeStructPropInfo<'a>> {
         self.details
             .properties
             .iter()


Test patch:
diff --git a/typify-impl/src/test_util.rs b/typify-impl/src/test_util.rs
index 2a9938f..bbc2fd4 100644
--- a/typify-impl/src/test_util.rs
+++ b/typify-impl/src/test_util.rs
@@ -1,4 +1,4 @@
-// Copyright 2022 Oxide Computer Company
+// Copyright 2025 Oxide Computer Company
 
 use std::{any::type_name, collections::HashSet};
 
@@ -12,7 +12,7 @@ use syn::{
     FieldsNamed, FieldsUnnamed, File, Type, TypePath, TypeTuple, Variant,
 };
 
-use crate::{output::OutputSpace, Name, RefKey, TypeId, TypeSpace};
+use crate::{output::OutputSpace, RefKey, TypeId, TypeSpace};
 
 pub(crate) fn get_type<T: JsonSchema>() -> (TypeSpace, TypeId) {
     let schema = schema_for!(T);
@@ -141,40 +141,6 @@ fn decanonicalize_std_types(mut input: DeriveInput) -> DeriveInput {
     input
 }
 
-#[macro_export]
-macro_rules! validate_builtin {
-    ($t:ty) => {
-        $crate::test_util::validate_builtin_impl::<$t>(stringify!($t))
-    };
-}
-
-#[track_caller]
-pub(crate) fn validate_builtin_impl<T: JsonSchema>(name: &str) {
-    let schema = schema_for!(T);
-    let original_schema = schemars::schema::Schema::Object(schema.schema.clone());
-
-    let mut type_space = TypeSpace::default();
-    type_space
-        .add_ref_types(schema.definitions.clone())
-        .unwrap();
-    let (ty, _) = type_space
-        .convert_schema_object(Name::Unknown, &original_schema, &schema.schema)
-        .unwrap();
-
-    let output = ty.type_ident(&type_space, &None);
-
-    let actual = syn::parse2::<syn::Type>(output.clone()).unwrap();
-    let expected = syn::parse_str::<syn::Type>(name).unwrap();
-
-    // Make sure they match.
-    if let Err(err) = expected.syn_cmp(&actual, false) {
-        println!("{:#?}", schema);
-        println!("actual: {}", output);
-        println!("expected: {}", name);
-        panic!("{}", err);
-    }
-}
-
 pub(crate) trait SynCompare {
     fn syn_cmp(&self, other: &Self, ignore_variant_names: bool) -> Result<(), String>;
 }