What does an "implementation of `FnOnce` is not general enough" error mean?
05:48 05 Feb 2026

Let's say we have a trait like the following, which is a distillation of how view types work in protobuf::Message:

trait Message {
    type View<'a>;
}

We are implementing an RPC system, so we define a trait for functions that know how to deal with an incoming message. (In reality we need this to make more requirements on the result type, like that it be Future + Send).

trait HandlerFn {}

impl HandlerFn for F
where
    Request: Message,
    F: Fn(Request::View<'_>) -> R,
{
}

We try to check whether the simplest possible handler implements this trait:

fn check_handler_fn(_: impl HandlerFn) {}

fn foo() {
    check_handler_fn::(|_| -> () { todo!() });
}

But this fails to build, with the following not-very-helpful error message:

error: implementation of `FnOnce` is not general enough
  --> src/lib.rs:17:5
   |
17 |     check_handler_fn::(|_| -> () { todo!() });
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
   |
   = note: closure with signature `fn(::View<'0>)` must implement `FnOnce<(::View<'_>,)>`, for some specific lifetime `'0`...
   = note: ...but it actually implements `FnOnce<(::View<'1>,)>`, for some specific lifetime `'1`

(Playground)

What does this error mean? How can I repair the problem, teaching the compiler that the closure doesn't care about a particular lifetime?

rust traits