Unit test of feature checks propagating through function pointers.

I had thought they didn't, but I misread the code, and mis-constructed my original test, oops.

PiperOrigin-RevId: 660116153
Change-Id: Ic5708b1e63e16fa70a104435a5050bf7c3dbbc14
diff --git a/rs_bindings_from_cc/generate_bindings/rs_snippet.rs b/rs_bindings_from_cc/generate_bindings/rs_snippet.rs
index a9a2deb..c585314 100644
--- a/rs_bindings_from_cc/generate_bindings/rs_snippet.rs
+++ b/rs_bindings_from_cc/generate_bindings/rs_snippet.rs
@@ -1035,4 +1035,39 @@
         assert_eq!(result.features, [make_rs_ident("arbitrary_self_types")].into_iter().collect());
         Ok(())
     }
+
+    /// Basic unit test of required_crubit_features on a compound data type.
+    ///
+    /// If a nested type within it requires a feature, then the whole feature
+    /// does. This is done automatically via dfs_iter().
+    #[test]
+    fn test_required_crubit_features() {
+        let no_types: &[RsTypeKind] = &[];
+        let int = RsTypeKind::Primitive(PrimitiveType::i32);
+        let reference = RsTypeKind::Reference {
+            referent: Rc::new(int.clone()),
+            mutability: Mutability::Const,
+            lifetime: Lifetime::new("_"),
+        };
+        for func_ptr in [
+            RsTypeKind::FuncPtr {
+                abi: "C".into(),
+                return_type: Rc::new(reference.clone()),
+                param_types: no_types.into(),
+            },
+            RsTypeKind::FuncPtr {
+                abi: "C".into(),
+                return_type: Rc::new(int),
+                param_types: Rc::from([reference]),
+            },
+        ] {
+            let (missing_features, reason) =
+                func_ptr.required_crubit_features(<flagset::FlagSet<ir::CrubitFeature>>::default());
+            assert_eq!(
+                missing_features,
+                ir::CrubitFeature::Experimental | ir::CrubitFeature::Supported
+            );
+            assert_eq!(reason, "references are not supported");
+        }
+    }
 }