Skip to content

Commit c09f183

Browse files
committed
Bless
1 parent e47d32e commit c09f183

6 files changed

+46
-9
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
| ^^^^

tests/ui/lang-items/lang-item-generic-requirements.rs

+2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ fn ice() {
4949
// Use index
5050
let arr = [0; 5];
5151
let _ = arr[2];
52+
//~^ ERROR: cannot index into a value of type
5253

5354
// Use phantomdata
5455
let _ = MyPhantomData::<(), i32>;
5556

5657
// Use Foo
5758
let _: () = Foo;
59+
//~^ ERROR: mismatched types
5860
}
5961

6062
// use `start`

tests/ui/lang-items/lang-item-generic-requirements.stderr

+17-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,23 @@ LL | r + a;
7676
| |
7777
| {integer}
7878

79+
error[E0608]: cannot index into a value of type `[{integer}; 5]`
80+
--> $DIR/lang-item-generic-requirements.rs:51:16
81+
|
82+
LL | let _ = arr[2];
83+
| ^^^
84+
85+
error[E0308]: mismatched types
86+
--> $DIR/lang-item-generic-requirements.rs:58:17
87+
|
88+
LL | let _: () = Foo;
89+
| -- ^^^ expected `()`, found `Foo`
90+
| |
91+
| expected due to this
92+
7993
error: requires `copy` lang_item
8094

81-
error: aborting due to 10 previous errors
95+
error: aborting due to 12 previous errors
8296

83-
Some errors have detailed explanations: E0369, E0392, E0718.
84-
For more information about an error, try `rustc --explain E0369`.
97+
Some errors have detailed explanations: E0308, E0369, E0392, E0608, E0718.
98+
For more information about an error, try `rustc --explain E0308`.

tests/ui/repeat-expr/infer-eager.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//@ check-pass
2-
31
use std::marker::PhantomData;
42

53
struct Foo<T>(PhantomData<T>);
@@ -17,5 +15,6 @@ fn extract<T, const N: usize>(_: [Foo<T>; N]) -> T {
1715

1816
fn main() {
1917
let x = [Foo(PhantomData); 2];
18+
//~^ ERROR: type annotations needed
2019
_ = extract(x).max(2);
2120
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0282]: type annotations needed for `[Foo<_>; 2]`
2+
--> $DIR/infer-eager.rs:17: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`.

0 commit comments

Comments
 (0)