Skip to content

Note when trait bound may be satisfied for a different version of a crate #78552

Description

@Aaron1011

On the playground, the following code:

use bytes::Bytes;
use http::Response;
use hyper::Body;

pub fn build(data: Bytes) -> Response<Body> {
    Response::new(data.into())
}

fn main() {
}

currently produces the following error:

error[E0277]: the trait bound `hyper::Body: std::convert::From<bytes::Bytes>` is not satisfied
 --> src/main.rs:6:19
  |
6 |     Response::new(data.into())
  |                   ^^^^^^^^^^^ the trait `std::convert::From<bytes::Bytes>` is not implemented for `hyper::Body`
  |
  = help: the following implementations were found:
            <hyper::Body as std::convert::From<&'static [u8]>>
            <hyper::Body as std::convert::From<&'static str>>
            <hyper::Body as std::convert::From<hyper::body::Bytes>>
            <hyper::Body as std::convert::From<std::borrow::Cow<'static, [u8]>>>
          and 4 others
  = note: required because of the requirements on the impl of `std::convert::Into<hyper::Body>` for `bytes::Bytes`

Note that hyper::body::Bytes is an alias for bytes::Bytes. We should detect when an unment trait bound's substs match the fully-qualified names of our desired trait bound, and note that multiple versions of the same crate may be in use.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemD-confusingDiagnostics: Confusing error or lint that should be reworked.D-crate-version-mismatchDiagnostics: Errors or lints caused be the use of two different crate versions.S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions