Suggest inline const blocks for array initialization · rust-lang/rust@ba5ec1f

@@ -2,45 +2,36 @@ error[E0277]: the trait bound `String: Copy` is not satisfied

22

--> $DIR/const-fn-in-vec.rs:1:47

33

|

44

LL | static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5];

5-

| ^^^^ the trait `Copy` is not implemented for `String`, which is required by `Option<String>: Copy`

5+

| ^^^^

6+

| |

7+

| the trait `Copy` is not implemented for `String`, which is required by `Option<String>: Copy`

8+

| help: create an inline `const` block: `const { None }`

69

|

710

= note: required for `Option<String>` to implement `Copy`

811

= note: the `Copy` trait is required because this value will be copied for each element of the array

9-

= help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information

10-

help: consider creating a new `const` item and initializing it with the result of the constructor to be used in the repeat position

11-

|

12-

LL + const ARRAY_REPEAT_VALUE: Option<String> = None;

13-

LL ~ static _MAYBE_STRINGS: [Option<String>; 5] = [ARRAY_REPEAT_VALUE; 5];

14-

|

15121613

error[E0277]: the trait bound `String: Copy` is not satisfied

1714

--> $DIR/const-fn-in-vec.rs:7:34

1815

|

1916

LL | let _strings: [String; 5] = [String::new(); 5];

20-

| ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`

17+

| ^^^^^^^^^^^^^

18+

| |

19+

| the trait `Copy` is not implemented for `String`

20+

| help: create an inline `const` block: `const { String::new() }`

2121

|

2222

= note: the `Copy` trait is required because this value will be copied for each element of the array

23-

= help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information

24-

help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position

25-

|

26-

LL ~ const ARRAY_REPEAT_VALUE: String = String::new();

27-

LL ~ let _strings: [String; 5] = [ARRAY_REPEAT_VALUE; 5];

28-

|

29233024

error[E0277]: the trait bound `String: Copy` is not satisfied

3125

--> $DIR/const-fn-in-vec.rs:9:48

3226

|

3327

LL | let _maybe_strings: [Option<String>; 5] = [None; 5];

34-

| ^^^^ the trait `Copy` is not implemented for `String`, which is required by `Option<String>: Copy`

28+

| ^^^^

29+

| |

30+

| the trait `Copy` is not implemented for `String`, which is required by `Option<String>: Copy`

31+

| help: create an inline `const` block: `const { None }`

3532

|

3633

= note: required for `Option<String>` to implement `Copy`

3734

= note: the `Copy` trait is required because this value will be copied for each element of the array

38-

= help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information

39-

help: consider creating a new `const` item and initializing it with the result of the constructor to be used in the repeat position

40-

|

41-

LL ~ const ARRAY_REPEAT_VALUE: Option<String> = None;

42-

LL ~ let _maybe_strings: [Option<String>; 5] = [ARRAY_REPEAT_VALUE; 5];

43-

|

44354536

error: aborting due to 3 previous errors

4637