]> git.lizzy.rs Git - rust.git/blob - tests/ui/closures/closure-reform-bad.stderr
Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
[rust.git] / tests / ui / closures / closure-reform-bad.stderr
1 error[E0308]: mismatched types
2   --> $DIR/closure-reform-bad.rs:11:15
3    |
4 LL |     let f = |s: &str| println!("{}{}", s, string);
5    |             --------- the found closure
6 LL |     call_bare(f)
7    |     --------- ^ expected fn pointer, found closure
8    |     |
9    |     arguments to this function are incorrect
10    |
11    = note: expected fn pointer `for<'a> fn(&'a str)`
12                  found closure `[closure@$DIR/closure-reform-bad.rs:10:13: 10:22]`
13 note: closures can only be coerced to `fn` types if they do not capture any variables
14   --> $DIR/closure-reform-bad.rs:10:43
15    |
16 LL |     let f = |s: &str| println!("{}{}", s, string);
17    |                                           ^^^^^^ `string` captured here
18 note: function defined here
19   --> $DIR/closure-reform-bad.rs:4:4
20    |
21 LL | fn call_bare(f: fn(&str)) {
22    |    ^^^^^^^^^ -----------
23
24 error: aborting due to previous error
25
26 For more information about this error, try `rustc --explain E0308`.