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

Support non-static lifetime inside error(transparent) #134

Merged
merged 2 commits into from May 22, 2021
Merged

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented May 22, 2021

Fixes #113.

This does not currently compile.

    error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
      --> tests/test_transparent.rs:63:14
       |
    63 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 65:18...
      --> tests/test_transparent.rs:65:18
       |
    65 |     struct Error<'a> {
       |                  ^^
    note: ...so that the types are compatible
      --> tests/test_transparent.rs:63:14
       |
    63 |     #[derive(Error, Debug)]
       |              ^^^^^
       = note: expected `&test_non_static::ErrorKind<'_>`
                  found `&test_non_static::ErrorKind<'a>`
       = note: but, the lifetime must be valid for the static lifetime...
    note: ...so that the type `test_non_static::ErrorKind<'_>` will meet its required lifetime bounds
      --> tests/test_transparent.rs:63:14
       |
    63 |     #[derive(Error, Debug)]
       |              ^^^^^
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
@dtolnay dtolnay merged commit e49c10f into master May 22, 2021
@dtolnay dtolnay deleted the nonstatic branch May 22, 2021 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lifetimes and #[error(transparent)]
1 participant