Permit mut from ref in unsafe-to-call signatures
diff --git a/syntax/check.rs b/syntax/check.rs
index 6ba6565..1e52c2e 100644
--- a/syntax/check.rs
+++ b/syntax/check.rs
@@ -508,6 +508,11 @@
}
fn check_mut_return_restriction(cx: &mut Check, efn: &ExternFn) {
+ if efn.sig.unsafety.is_some() {
+ // Unrestricted as long as the function is made unsafe-to-call.
+ return;
+ }
+
match &efn.ret {
Some(Type::Ref(ty)) if ty.mutable => {}
_ => return,
diff --git a/tests/ui/mut_return.stderr b/tests/ui/mut_return.stderr
index 6b091d7..d6ddb88 100644
--- a/tests/ui/mut_return.stderr
+++ b/tests/ui/mut_return.stderr
@@ -3,9 +3,3 @@
|
6 | fn f(t: &Thing) -> Pin<&mut CxxString>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: &mut return type is not allowed unless there is a &mut argument
- --> $DIR/mut_return.rs:7:9
- |
-7 | unsafe fn g(t: &Thing) -> Pin<&mut CxxString>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^