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

Associated type default and From #47385

Closed
valff opened this issue Jan 12, 2018 · 0 comments · Fixed by #61812
Closed

Associated type default and From #47385

valff opened this issue Jan 12, 2018 · 0 comments · Fixed by #61812
Assignees
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. F-associated_type_defaults `#![feature(associated_type_defaults)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@valff
Copy link
Contributor

valff commented Jan 12, 2018

Associated type defaults seem broken in the following case: (play)

#![feature(associated_type_defaults)]

pub struct Foo;

pub trait Bar: From<<Self as Bar>::Input> {
    type Input = Self;
}

impl Bar for Foo {
    // Will compile with explicit type:
    // type Input = Self;
}

fn main() {}

Compile error:

error[E0277]: the trait bound `Foo: std::convert::From<<Foo as Bar>::Input>` is not satisfied
 --> src/main.rs:9:6
  |
9 | impl Bar for Foo {
  |      ^^^ the trait `std::convert::From<<Foo as Bar>::Input>` is not implemented for `Foo`

However if I uncomment type Input = Self in impl, it will work. It is confusing, because Input should be already set to Self in the default case.

@pietroalbini pietroalbini added A-associated-items Area: Associated items (types, constants & functions) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 6, 2018
@jonas-schievink jonas-schievink added the F-associated_type_defaults `#![feature(associated_type_defaults)]` label Aug 29, 2019
@jonas-schievink jonas-schievink self-assigned this Aug 29, 2019
@jonas-schievink jonas-schievink added the requires-nightly This issue requires a nightly compiler in some way. label Jan 4, 2020
@bors bors closed this as completed in 3a0d106 Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. F-associated_type_defaults `#![feature(associated_type_defaults)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants