Skip to content

Commit 8966d60

Browse files
committed
Bless
1 parent 2d7d6e8 commit 8966d60

6 files changed

+37
-5
lines changed

tests/ui/consts/const-fn-in-vec.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5];
22
//~^ ERROR the trait bound `String: Copy` is not satisfied
33

4-
fn main() {
5-
// should hint to create an inline `const` block
6-
// or to create a new `const` item
4+
// should hint to create an inline `const` block
5+
// or to create a new `const` item
6+
fn foo() {
77
let _strings: [String; 5] = [String::new(); 5];
88
//~^ ERROR the trait bound `String: Copy` is not satisfied
9+
}
10+
11+
fn bar() {
912
let _maybe_strings: [Option<String>; 5] = [None; 5];
1013
//~^ ERROR the trait bound `String: Copy` is not satisfied
1114
}
15+
16+
fn main() {}

tests/ui/consts/const-fn-in-vec.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ LL | let _strings: [String; 5] = [String::new(); 5];
2222
= note: the `Copy` trait is required because this value will be copied for each element of the array
2323

2424
error[E0277]: the trait bound `String: Copy` is not satisfied
25-
--> $DIR/const-fn-in-vec.rs:9:48
25+
--> $DIR/const-fn-in-vec.rs:12:48
2626
|
2727
LL | let _maybe_strings: [Option<String>; 5] = [None; 5];
2828
| ^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0282]: type annotations needed for `[Foo<_>; 2]`
2+
--> $DIR/copy-inference-side-effects-are-lazy.rs:22:9
3+
|
4+
LL | let x = [Foo(PhantomData); 2];
5+
| ^
6+
LL |
7+
LL | _ = extract(x).max(2);
8+
| ---------- type must be known at this point
9+
|
10+
help: consider giving `x` an explicit type, where the type for type parameter `T` is specified
11+
|
12+
LL | let x: [Foo<T>; 2] = [Foo(PhantomData); 2];
13+
| +++++++++++++
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0282`.

tests/ui/repeat-expr/infer-eager.rs renamed to tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
//@ check-pass
1+
//@revisions: current gai
2+
//@[current] check-pass
3+
4+
#![cfg_attr(gai, feature(generic_arg_infer))]
25

36
use std::marker::PhantomData;
47

@@ -17,5 +20,6 @@ fn extract<T, const N: usize>(_: [Foo<T>; N]) -> T {
1720

1821
fn main() {
1922
let x = [Foo(PhantomData); 2];
23+
//[gai]~^ ERROR: type annotations needed
2024
_ = extract(x).max(2);
2125
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ check-pass
2+
#![feature(generic_arg_infer)]
3+
4+
fn main() {
5+
let a: [_; 1] = [String::new(); _];
6+
}

0 commit comments

Comments
 (0)