Skip to content

Commit dbe56f4

Browse files
author
Sasha Pourcelot
committed
Add ruby-style closure ui tests
1 parent e8e76b7 commit dbe56f4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let p = Some(45).and_then({
3+
//~^ expected a `FnOnce<({integer},)>` closure, found `Option<_>`
4+
|x| println!("doubling {}", x);
5+
Some(x * 2)
6+
//~^ ERROR: cannot find value `x` in this scope
7+
});
8+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0425]: cannot find value `x` in this scope
2+
--> $DIR/ruby_style_closure.rs:5:14
3+
|
4+
LL | Some(x * 2)
5+
| ^ not found in this scope
6+
7+
error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
8+
--> $DIR/ruby_style_closure.rs:2:22
9+
|
10+
LL | let p = Some(45).and_then({
11+
| ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
12+
|
13+
= help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
14+
15+
error: aborting due to 2 previous errors
16+
17+
Some errors have detailed explanations: E0277, E0425.
18+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)