With the code
fn foo(env: &mut String)
-> impl FnMut(&str) -> nom::IResult<&str, &str> {
nom::bytes::complete::tag("foo")
}
on rustc 1.55.0 and nom 7 I get the error
error[E0308]: mismatched types
--> src/mve.rs:2:8
|
2 | -> impl FnMut(&str) -> nom::IResult<&str, &str> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
::: /Users/dan/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-7.0.0/src/bytes/complete.rs:35:6
|
35 | ) -> impl Fn(Input) -> IResult<Input, Input, Error>
| ----------------------------------------------
| |
| the expected opaque type
| the found opaque type
|
= note: expected associated type `<impl Fn<(&str,)> as FnOnce<(&str,)>>::Output`
found associated type `<impl Fn<(&str,)> as FnOnce<(&str,)>>::Output`
Why are the expected and found types the same? This seems like a bug to me. (Unfortunately I couldn't find an example for the error that didn't involve nom.)