Skip to content

Commit 668b954

Browse files
committed
add a test for weakened closure signature inference
1 parent 6ab8f33 commit 668b954

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Weakened closure sig inference by #140283.
2+
fn foo<F: FnOnce(&str) -> usize, const N: usize>(x: [F; N]) {}
3+
4+
fn main() {
5+
foo([|s| s.len()])
6+
//~^ ERROR: type annotations needed
7+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/closure-in-array.rs:5:11
3+
|
4+
LL | foo([|s| s.len()])
5+
| ^ - type must be known at this point
6+
|
7+
help: consider giving this closure parameter an explicit type
8+
|
9+
LL | foo([|s: /* Type */| s.len()])
10+
| ++++++++++++
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)