Recognize mutable slice in return position of a safe function

This commit is contained in:
David Tolnay 2021-03-28 03:55:34 -04:00
parent 6ca15ddb0c
commit 22cb28882a
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 7 additions and 0 deletions

View File

@ -514,6 +514,7 @@ fn check_mut_return_restriction(cx: &mut Check, efn: &ExternFn) {
match &efn.ret {
Some(Type::Ref(ty)) if ty.mutable => {}
Some(Type::SliceRef(slice)) if slice.mutable => {}
_ => return,
}

View File

@ -3,3 +3,9 @@ error: &mut return type is not allowed unless there is a &mut argument
|
10 | fn f(t: &Thing) -> Pin<&mut CxxString>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: &mut return type is not allowed unless there is a &mut argument
--> $DIR/mut_return.rs:14:9
|
14 | fn j(t: &Thing) -> &mut [u8];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^