asomers / mockall

A powerful mock object library for Rust
Apache License 2.0
1.5k stars 62 forks source link

<'a, T: Foo + 'a> = undeclared lifetime #423

Closed WilliamVenner closed 1 year ago

WilliamVenner commented 1 year ago
mock! {
    pub Foo {}
    impl Bar for Foo {
        fn baz<'a, T: Qux + 'a>(&self);
    }
}

error[E0261]: use of undeclared lifetime name `'a`
  --> src/tests/mocks/mod.rs:8:29
   |
8  |         fn baz<'a, T: Qux + 'a>(&self);
   |                -            ^^ undeclared lifetime
   |                |
   |                help: consider introducing lifetime `'a` here: `'a,`
...
51 | }
   |  - lifetime `'a` is missing in item created through this procedural macro

Using where does not workaround the issue.

asomers commented 1 year ago

This is a documented limitation. See https://docs.rs/mockall/latest/mockall/#methods-with-generic-lifetime .