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

Could not find future in core #109

Closed
alex-dukhno opened this issue Jun 16, 2020 · 4 comments
Closed

Could not find future in core #109

alex-dukhno opened this issue Jun 16, 2020 · 4 comments

Comments

@alex-dukhno
Copy link

alex-dukhno commented Jun 16, 2020

Hi there,

I've got the following case:

// crate `interface`
#[async_trait]
pub trait MyInterface {
  async fn function() -> Result<(), Error>;
}

// crate `implementation`
pub struct Implementation;
 
#[async_trait]
impl MyInterface for Implementation {
  async fn function() -> Result<(), Error> {
    Ok(())
  }
}

when I compiling the project I got the following compiler error:

error[E0433]: failed to resolve: could not find `pin` in `core`
  --> src/node/src/query_listener.rs:32:1
   |
32 | #[async_trait]
   | ^^^^^^^^^^^^^^ could not find `pin` in `core`

error[E0433]: failed to resolve: could not find `future` in `core`
  --> src/node/src/query_listener.rs:32:1
   |
32 | #[async_trait]
   | ^^^^^^^^^^^^^^ could not find `future` in `core`

error[E0433]: failed to resolve: could not find `marker` in `core`
  --> src/node/src/query_listener.rs:32:1
   |
32 | #[async_trait]
   | ^^^^^^^^^^^^^^ could not find `marker` in `core`

Thank you

@dtolnay
Copy link
Owner

dtolnay commented Jun 16, 2020

Can you provide a minimal git repo or something which I could cargo build to reproduce this?

@alex-dukhno
Copy link
Author

alex-dukhno commented Jun 16, 2020

Hi, thank you for quick response.

Seems like the case is much more complicated then I thought ...
I created repo https://github.com/alex-dukhno/async-trait-cross-crates-compilation, but I couldn't reproduce the exact error ... but I got the other ...
Trait has Self::Item return value in
https://github.com/alex-dukhno/async-trait-cross-crates-compilation/blob/master/src/interface/src/lib.rs#L9
but I had to return reference in impl https://github.com/alex-dukhno/async-trait-cross-crates-compilation/blob/master/src/implementation/src/some_module.rs#L14 otherwise I got compilation error

error[E0053]: method `item` has an incompatible type for trait
  --> src/implementation/src/some_module.rs:14:5
   |
14 |     fn item(&self) -> Self::Item {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&some_module::OtherImplementation`, found struct `some_module::OtherImplementation`
   |
   = note: expected fn pointer `fn(&some_module::Implementation) -> &some_module::OtherImplementation`
              found fn pointer `fn(&some_module::Implementation) -> some_module::OtherImplementation`

I don't know if it suits you but I can give you a link to the branch of my repo where original problem can be reproduced. Here it is https://github.com/alex-dukhno/database/tree/initial-extraction-of-api-for-pg-wire-protocol

@dtolnay
Copy link
Owner

dtolnay commented Jun 16, 2020

It looks like you've provided your own implementation of core here which has an API that is different from libcore (https://doc.rust-lang.org/core/). Similar to std, core is reserved in Rust to refer to crates which provide the API of libcore, so I am not surprised that it leads to problems. I'll close this issue since a nonstandard libcore is not a setup that we could support.

@dtolnay dtolnay closed this as completed Jun 16, 2020
@dtolnay dtolnay changed the title impl Trait in another crate can't be compiled Could not find future in core Jun 16, 2020
@alex-dukhno
Copy link
Author

Thanks. Then I’ll rename the create

e00E added a commit to gnosis/dex-services that referenced this issue Aug 31, 2020
It turns out that it is bad idea to have a crate named `core`. The name
is already used in the standard library which can confuse for example
macros in dependencies that want to refer to the real `core` crate. I
encounted this when trying to use the async-trait macro
dtolnay/async-trait#109 .
e00E added a commit to gnosis/dex-services that referenced this issue Aug 31, 2020
It turns out that it is bad idea to have a crate named `core`. The name
is already used in the standard library which can confuse for example
macros in dependencies that want to refer to the real `core` crate. I
encounted this when trying to use the async-trait macro
dtolnay/async-trait#109 .
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

No branches or pull requests

2 participants