Skip to content

Associated type constraints on supertraits don't propagate to usage sites #36978

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

Closed
Twey opened this issue Oct 5, 2016 · 1 comment
Closed
Labels
A-associated-items Area: Associated items (types, constants & functions) A-trait-system Area: Trait system

Comments

@Twey
Copy link

Twey commented Oct 5, 2016

Consider the following:

trait Foo { type FooT; }
trait Bar { }
trait FooBar: Foo<FooT=usize> + Bar { }
type BoxedFooBar = Box<FooBar>;

Since the value of FooT is known from the definition of FooBar, line 4 should be fine — if FB: FooBar then necessarily FB::FooT = usize. However, this fails to compile with rustc 1.12.0, with the error:

error[E0191]: the value of the associated type `FooT` (from the trait `Foo`) must be specified
 --> <anon>:4:24
  |
4 | type BoxedFooBar = Box<FooBar>;
  |                        ^^^^^^ missing associated type `FooT` value

To make it compile, one must duplicate the information at every use-site:

trait Foo { type FooT; }
trait Bar { }
trait FooBar: Foo<FooT=usize> + Bar { }
type BoxedFooBar = Box<FooBar<FooT=usize>>;
@apasel422
Copy link
Contributor

Seems to be a duplicate of #23856.

@apasel422 apasel422 added A-trait-system Area: Trait system A-associated-items Area: Associated items (types, constants & functions) labels Oct 5, 2016
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) A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

2 participants