Skip to content

Commit 6344245

Browse files
Rollup merge of rust-lang#141594 - BoxyUwU:another_gai_test, r=jieyouxu
Add `generic_arg_infer` test I think most of our existing tests around behaviour of repeat expr inferred counts fail by not having enough inference progress, rather than by having enough inference progress but the element not actually implementing `Copy`.
2 parents 38d1862 + c27aff3 commit 6344245

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)