@@ -967,6 +967,50 @@ You can find more information about borrowing in the rust-book:
967
967
http://doc.rust-lang.org/stable/book/references-and-borrowing.html
968
968
"## ,
969
969
970
+ E0508 : r##"
971
+ A value was moved out of a non-copy fixed-size array.
972
+
973
+ Example of erroneous code:
974
+
975
+ ```compile_fail
976
+ struct NonCopy;
977
+
978
+ fn main() {
979
+ let array = [NonCopy; 1];
980
+ let _value = array[0]; // error: cannot move out of type `[NonCopy; 1]`,
981
+ // a non-copy fixed-size array
982
+ }
983
+ ```
984
+
985
+ The first element was moved out of the array, but this is not
986
+ possible because `NonCopy` does not implement the `Copy` trait.
987
+
988
+ Consider borrowing the element instead of moving it:
989
+
990
+ ```
991
+ struct NonCopy;
992
+
993
+ fn main() {
994
+ let array = [NonCopy; 1];
995
+ let _value = &array[0]; // Borrowing is allowed, unlike moving.
996
+ }
997
+ ```
998
+
999
+ Alternatively, if your type implements `Clone` and you need to own the value,
1000
+ consider borrowing and then cloning:
1001
+
1002
+ ```
1003
+ #[derive(Clone)]
1004
+ struct NonCopy;
1005
+
1006
+ fn main() {
1007
+ let array = [NonCopy; 1];
1008
+ // Now you can clone the array element.
1009
+ let _value = array[0].clone();
1010
+ }
1011
+ ```
1012
+ "## ,
1013
+
970
1014
E0509 : r##"
971
1015
This error occurs when an attempt is made to move out of a value whose type
972
1016
implements the `Drop` trait.
@@ -1067,6 +1111,5 @@ fn main() {
1067
1111
register_diagnostics ! {
1068
1112
E0385 , // {} in an aliasable location
1069
1113
E0388 , // {} in a static location
1070
- E0508 , // cannot move out of type `..`, a non-copy fixed-size array
1071
1114
E0524 , // two closures require unique access to `..` at the same time
1072
1115
}
0 commit comments