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

error[E0700]: hidden type for impl Trait captures lifetime that does not appear in bounds #15

Closed
MOZGIII opened this issue Jul 27, 2019 · 2 comments · Fixed by #16
Closed

Comments

@MOZGIII
Copy link

MOZGIII commented Jul 27, 2019

With this seemingly ok code:

#![feature(async_await)]

use async_trait::async_trait;
use slog::Logger;

#[async_trait]
trait MyTrait {
    async fn myfn(&self, logger: Logger);
}

struct MyImpl;

#[async_trait]
impl MyTrait for MyImpl {
    async fn myfn(&self, _logger: Logger) {}
}

I get this odd error:

   Compiling redacted v0.1.0 (/redacted)
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
  --> tests/test.rs:15:43
   |
15 |     async fn myfn(&self, _logger: Logger) {}
   |                                           ^
   |
note: hidden type `impl std::future::Future` captures the scope of call-site for function at 15:43
  --> tests/test.rs:15:43
   |
15 |     async fn myfn(&self, _logger: Logger) {}
   |                                           ^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0700`.
error: Could not compile `redacted`.

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

The error is caused by slog::Logger.

This seems to be a bug. As a workaround, I'm currently passing the logger in a wrapper-struct, but I hope to get this solved.

PS: I have no idea what's going on here, and how to simplify the example further.

@dtolnay
Copy link
Owner

dtolnay commented Jul 27, 2019

Thanks! I filed this as a compiler bug: rust-lang/rust#63033. I will try to implement a workaround.

@dtolnay
Copy link
Owner

dtolnay commented Jul 27, 2019

Fixed in 0.1.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants