Detect pointer argument inside of function pointer
diff --git a/syntax/check.rs b/syntax/check.rs
index 2c03bdf..5430428 100644
--- a/syntax/check.rs
+++ b/syntax/check.rs
@@ -272,6 +272,17 @@
if ty.throws {
cx.error(ty, "function pointer returning Result is not supported yet");
}
+
+ for arg in &ty.args {
+ if let Type::Ptr(_) = arg.ty {
+ if ty.unsafety.is_none() {
+ cx.error(
+ arg,
+ "pointer argument requires that the function pointer be marked unsafe",
+ );
+ }
+ }
+ }
}
fn check_api_struct(cx: &mut Check, strct: &Struct) {
diff --git a/tests/ui/ptr_in_fnptr.stderr b/tests/ui/ptr_in_fnptr.stderr
new file mode 100644
index 0000000..372d4cd
--- /dev/null
+++ b/tests/ui/ptr_in_fnptr.stderr
@@ -0,0 +1,5 @@
+error: pointer argument requires that the function pointer be marked unsafe
+ --> $DIR/ptr_in_fnptr.rs:4:27
+ |
+4 | fn f(callback: fn(p: *const u8));
+ | ^^^^^^^^^^^^