Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Forbid unusable type aliases #22434

Closed
Stebalien opened this issue Feb 17, 2015 · 1 comment
Closed

Forbid unusable type aliases #22434

Stebalien opened this issue Feb 17, 2015 · 1 comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@Stebalien
Copy link
Contributor

As far as I can tell, the following type alias is unusable:

type I<'a> = &'a (Iterator + 'a);

This isn't a complete type because Iterator::Item is unspecified and isn't usable because there is no way to specify Iterator::Item (as far as I know) after the fact.

Personally, I feel type aliases like this should be compile time errors. I'm bringing this nitpick up now because fixing it is technically a breaking change .

@steveklabnik steveklabnik added A-type-system Area: Type system A-associated-items Area: Associated items (types, constants & functions) labels Feb 17, 2015
@jonas-schievink
Copy link
Contributor

type I<'a> = &'a (Iterator + 'a);

fn main() {}

now gives:

<anon>:1:19: 1:32 error: the value of the associated type `Item` (from the trait `core::iter::Iterator`) must be specified [E0191]
<anon>:1 type I<'a> = &'a (Iterator + 'a);
                           ^~~~~~~~~~~~~
<anon>:1:19: 1:32 help: see the detailed explanation for E0191
error: aborting due to previous error

So this looks fixed!

@sfackler sfackler added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 1, 2015
Stebalien added a commit to Stebalien/rust that referenced this issue Jun 18, 2016
bors added a commit that referenced this issue Jun 19, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

4 participants