Skip to content

TryFrom trait bound on trait definition complains about missing From impl #80484

Closed as not planned
@adamlesinski

Description

@adamlesinski

I tried this code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a9fcf72c4bbeb63baf3dffb724d37852

I expected it to compile successfully.

Instead, it fails to compile with the error:

error[E0277]: the trait bound `&'a <C as Container>::Item: From<&'a Wrapper>` is not satisfied

I do not expect that a From implementation is needed when implementing TryFrom.

If I remove the trait bound from the trait Container, and place it on the function foo instead, it works as expected: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a4bdca2f01cd2a33f85d18e5ebdb5181

Also, if the trait bound is changed to not include lifetimes or references, this works as well: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a2e8dbad7838e71b6c0b8a42fca57509

The issue happens on both Beta and Nightly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions