Skip to content

Commit c27aff3

Browse files
committed
Add test
1 parent b5eb989 commit c27aff3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(generic_arg_infer)]
2+
3+
// Test that we enforce repeat expr element types are `Copy` even
4+
// when the repeat count is only inferred at a later point in type
5+
// checking.
6+
7+
fn main() {
8+
let a = [String::new(); _];
9+
//~^ ERROR: the trait bound `String: Copy` is not satisfied
10+
let b: [_; 2] = a;
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0277]: the trait bound `String: Copy` is not satisfied
2+
--> $DIR/copy-check-when-count-inferred-later.rs:8:14
3+
|
4+
LL | let a = [String::new(); _];
5+
| ^^^^^^^^^^^^^
6+
| |
7+
| the trait `Copy` is not implemented for `String`
8+
| help: create an inline `const` block: `const { String::new() }`
9+
|
10+
= note: the `Copy` trait is required because this value will be copied for each element of the array
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)