diff options
| author | Michael Goulet <michael@errs.io> | 2025-05-27 13:01:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-27 13:01:41 +0200 |
| commit | 6344245e4fe33787e80c49648f3094cb10fa2bb2 (patch) | |
| tree | 5964eafd08be1b701cdba93513bf74843170ef22 | |
| parent | 38d18626b118de207a55f4003db7c5423e2be66a (diff) | |
| parent | c27aff35caad45093b52988994c2bc9b5631b544 (diff) | |
| download | rust-6344245e4fe33787e80c49648f3094cb10fa2bb2.tar.gz rust-6344245e4fe33787e80c49648f3094cb10fa2bb2.zip | |
Rollup merge of #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`.
| -rw-r--r-- | tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs | 11 | ||||
| -rw-r--r-- | tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr | 14 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs new file mode 100644 index 00000000000..b9d123cbefa --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs @@ -0,0 +1,11 @@ +#![feature(generic_arg_infer)] + +// Test that we enforce repeat expr element types are `Copy` even +// when the repeat count is only inferred at a later point in type +// checking. + +fn main() { + let a = [String::new(); _]; + //~^ ERROR: the trait bound `String: Copy` is not satisfied + let b: [_; 2] = a; +} diff --git a/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr new file mode 100644 index 00000000000..d974f5add50 --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/copy-check-when-count-inferred-later.rs:8:14 + | +LL | let a = [String::new(); _]; + | ^^^^^^^^^^^^^ + | | + | the trait `Copy` is not implemented for `String` + | help: create an inline `const` block: `const { String::new() }` + | + = note: the `Copy` trait is required because this value will be copied for each element of the array + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. |
