mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 15:19:44 +00:00
Recognize mutable slice in return position of a safe function
This commit is contained in:
parent
6ca15ddb0c
commit
22cb28882a
@ -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,
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
Loading…
Reference in New Issue
Block a user