added a suggestion to create a const item if the fn in the array repeat expression is a const fn
This commit is contained in:
parent
368275062f
commit
c2e849c022
7 changed files with 87 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ LL | let _: [Option<Bar>; 2] = [no_copy(); 2];
|
|||
= help: the following implementations were found:
|
||||
<Option<T> as Copy>
|
||||
= note: the `Copy` trait is required because the repeated element will be copied
|
||||
= help: create an inline `const` block, see PR #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
7
src/test/ui/consts/const-fn-in-vec.rs
Normal file
7
src/test/ui/consts/const-fn-in-vec.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fn main() {
|
||||
// should hint to create an inline const block
|
||||
// as all tests are on "nightly"
|
||||
let strings: [String; 5] = [String::new(); 5];
|
||||
//~^ ERROR the trait bound `String: Copy` is not satisfied
|
||||
println!("{:?}", strings);
|
||||
}
|
||||
12
src/test/ui/consts/const-fn-in-vec.stderr
Normal file
12
src/test/ui/consts/const-fn-in-vec.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0277]: the trait bound `String: Copy` is not satisfied
|
||||
--> $DIR/const-fn-in-vec.rs:4:32
|
||||
|
|
||||
LL | let strings: [String; 5] = [String::new(); 5];
|
||||
| ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
||||
|
|
||||
= note: the `Copy` trait is required because the repeated element will be copied
|
||||
= help: create an inline `const` block, see PR #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue