-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-inferenceArea: Type inferenceArea: Type inference
Description
Hi.
It compiles with a type annotation as in this code.
fn work() -> impl FnMut(&u32, Option<u32>) -> bool {
|current, msg| false
}
fn main() {}This code doesn't compile.
fn doesnt_work() -> Result<impl FnMut(&u32, Option<u32>) -> bool, ()> {
Ok(|current, msg| false)
}
fn main() {}error:
error[E0631]: type mismatch in closure arguments
--> src/main.rs:1:28
|
1 | fn doesnt_work() -> Result<impl FnMut(&u32, Option<u32>) -> bool, ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r u32, std::option::Option<u32>) -> _`
2 | Ok(|current, msg| false)
| -------------------- found signature of `fn(_, _) -> _`
|
= note: the return type of a function must have a statically known size
error[E0271]: type mismatch resolving `for<'r> <[closure@src/main.rs:2:8: 2:28] as std::ops::FnOnce<(&'r u32, std::option::Option<u32>)>>::Output == bool`
--> src/main.rs:1:28
|
1 | fn doesnt_work() -> Result<impl FnMut(&u32, Option<u32>) -> bool, ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime
|
= note: the return type of a function must have a statically known size
error: aborting due to 2 previous errors
Thanks to fix this issue.
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-inferenceArea: Type inferenceArea: Type inference