@@ -911,6 +911,50 @@ You can find more information about borrowing in the rust-book:
911
911
http://doc.rust-lang.org/stable/book/references-and-borrowing.html
912
912
"## ,
913
913
914
+ E0508 : r##"
915
+ A value was moved out of a non-copy fixed-size array.
916
+
917
+ Example of erroneous code:
918
+
919
+ ```compile_fail
920
+ struct NonCopy;
921
+
922
+ fn main() {
923
+ let array = [NonCopy; 1];
924
+ let _value = array[0]; // error: cannot move out of type `[NonCopy; 1]`,
925
+ // a non-copy fixed-size array
926
+ }
927
+ ```
928
+
929
+ The first element was moved out of the array, but this is not
930
+ possible because `NonCopy` does not implement the `Copy` trait.
931
+
932
+ Consider borrowing the element instead of moving it:
933
+
934
+ ```
935
+ struct NonCopy;
936
+
937
+ fn main() {
938
+ let array = [NonCopy; 1];
939
+ let _value = &array[0]; // Borrowing is allowed, unlike moving.
940
+ }
941
+ ```
942
+
943
+ Alternatively, if your type implements `Clone` and you need to own the value,
944
+ consider borrowing and then cloning:
945
+
946
+ ```
947
+ #[derive(Clone)]
948
+ struct NonCopy;
949
+
950
+ fn main() {
951
+ let array = [NonCopy; 1];
952
+ // Now you can clone the array element.
953
+ let _value = array[0].clone();
954
+ }
955
+ ```
956
+ "## ,
957
+
914
958
E0509 : r##"
915
959
This error occurs when an attempt is made to move out of a value whose type
916
960
implements the `Drop` trait.
@@ -1012,6 +1056,5 @@ register_diagnostics! {
1012
1056
E0385 , // {} in an aliasable location
1013
1057
E0388 , // {} in a static location
1014
1058
E0503 , // cannot use `..` because it was mutably borrowed
1015
- E0508 , // cannot move out of type `..`, a non-copy fixed-size array
1016
1059
E0524 , // two closures require unique access to `..` at the same time
1017
1060
}
0 commit comments