Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lifetimes do not match method in trait #42

Closed
technetos opened this issue Oct 21, 2019 · 1 comment · Fixed by #43
Closed

lifetimes do not match method in trait #42

technetos opened this issue Oct 21, 2019 · 1 comment · Fixed by #43
Labels
bug Something isn't working

Comments

@technetos
Copy link

When using async-trait the compiler reports that the lifetimes do not match when no lifetimes are specified. Specifying a lifetime resolves the issue even though the lifetime is never used.

This crate requires #![feature(proc_macro_hygiene)] and thus requires nightly.

$ cargo check                                                                                                                                                                                                               master
    Checking enzyme v0.1.0 (/usr/dataplus/enzyme)
    Checking user v0.1.0 (/usr/dataplus/enzyme/example/microservices/user)
error[E0195]: lifetime parameters or bounds on method `from_parts` do not match the trait declaration
  --> src/context.rs:10:24
   |
10 |     async fn from_parts(_parts: Parts, _params: Params) -> WebResult<TokenContext> {
   |                        ^ lifetimes do not match method in trait

error[E0195]: lifetime parameters or bounds on method `from_parts` do not match the trait declaration
  --> src/context.rs:21:24
   |
21 |     async fn from_parts(parts: Parts, _params: Params) -> WebResult<AuthContext> {
   |                        ^ lifetimes do not match method in trait

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0195`.
error: could not compile `user`.

To learn more, run the command again with --verbose.

Trait Definition:

https://github.com/technetos/enzyme/blob/master/src/context.rs#L7

Trait Usage:

https://github.com/technetos/enzyme/blob/master/example/microservices/user/src/context.rs#L10
and
https://github.com/technetos/enzyme/blob/master/example/microservices/user/src/context.rs#L21

Method of reproduction:

Remove the <'a> lifetime from the trait definition and the usages above. Run cargo check

@dtolnay
Copy link
Owner

dtolnay commented Oct 21, 2019

Thanks! Should be fixed in 0.1.16.

@dtolnay dtolnay added the bug Something isn't working label Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants