mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
41e8d152dc
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
27 lines
962 B
Plaintext
27 lines
962 B
Plaintext
error[E0308]: mismatched types
|
|
--> $DIR/closure-reform-bad.rs:11:15
|
|
|
|
|
LL | let f = |s: &str| println!("{}{}", s, string);
|
|
| --------- the found closure
|
|
LL | call_bare(f)
|
|
| --------- ^ expected fn pointer, found closure
|
|
| |
|
|
| arguments to this function are incorrect
|
|
|
|
|
= note: expected fn pointer `for<'a> fn(&'a str)`
|
|
found closure `{closure@$DIR/closure-reform-bad.rs:10:13: 10:22}`
|
|
note: closures can only be coerced to `fn` types if they do not capture any variables
|
|
--> $DIR/closure-reform-bad.rs:10:43
|
|
|
|
|
LL | let f = |s: &str| println!("{}{}", s, string);
|
|
| ^^^^^^ `string` captured here
|
|
note: function defined here
|
|
--> $DIR/closure-reform-bad.rs:4:4
|
|
|
|
|
LL | fn call_bare(f: fn(&str)) {
|
|
| ^^^^^^^^^ -----------
|
|
|
|
error: aborting due to 1 previous error
|
|
|
|
For more information about this error, try `rustc --explain E0308`.
|