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

Upgrade from 0.1.42 to 0.1.43 triggers clippy::type_complexity #145

Closed
djc opened this issue Mar 5, 2021 · 3 comments · Fixed by #146
Closed

Upgrade from 0.1.42 to 0.1.43 triggers clippy::type_complexity #145

djc opened this issue Mar 5, 2021 · 3 comments · Fixed by #146

Comments

@djc
Copy link

djc commented Mar 5, 2021

I'm getting this:

warning: very complex type used. Consider factoring parts into `type` definitions
   --> bb8/src/api.rs:261:14
    |
261 |     async fn connect(&self) -> Result<Self::Connection, Self::Error>;
    |              ^^^^^^^
    |
    = note: `#[warn(clippy::type_complexity)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity

for this trait definition in bb8:

/// A trait which provides connection-specific functionality.
#[async_trait]
pub trait ManageConnection: Sized + Send + Sync + 'static {
    /// The connection type this manager deals with.
    type Connection: Send + 'static;
    /// The error type returned by `Connection`s.
    type Error: fmt::Debug + Send + 'static;

    /// Attempts to create a new connection.
    async fn connect(&self) -> Result<Self::Connection, Self::Error>;
    /// Determines if the connection is still connected to the database.
    async fn is_valid(&self, conn: &mut PooledConnection<'_, Self>) -> Result<(), Self::Error>;
    /// Synchronously determine if the connection is no longer usable, if possible.
    fn has_broken(&self, conn: &mut Self::Connection) -> bool;
}

Should I suppress this on my side, or is that something the async-trait macro could/should do?

@dtolnay
Copy link
Owner

dtolnay commented Mar 5, 2021

The future coming out of async-trait is something like ::core::pin::Pin<Box<dyn ::core::future::Future<Output = Result<Self::Connection, Self::Error>> + ::core::marker::Send + 'async_trait>> which is indeed complex! Sorry about the breakage. This needs to be fixed in async-trait with a suppression because it isn't really the caller code's "fault".

@dtolnay
Copy link
Owner

dtolnay commented Mar 5, 2021

I released 0.1.44 with a fix.

@djc
Copy link
Author

djc commented Mar 5, 2021

Great, thanks for the quick response!

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 a pull request may close this issue.

2 participants