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

Prohibit unused type parameters in impls. #20593

Merged
merged 4 commits into from
Jan 7, 2015

Conversation

nikomatsakis
Copy link
Contributor

@aturon
Copy link
Member

aturon commented Jan 6, 2015

r=me after a rebase

@nikomatsakis
Copy link
Contributor Author

r=aturon

parameters on impls must now also appear in the trait ref, self type,
or some associated type declared on the impl. This ensures that they
are constrianed in some way and that the semantics of the trait system
are well-defined (always a good thing).

There are three major ways to fix this error:

1. Convert the trait to use associated types; most often the type
   parameters are not constrained because they are in fact outputs of
   the impl.

2. Move the type parameters to methods.

3. Add an additional type parameter to the self type or trait so that
   the unused parameter can appear there.

In some cases, it is not possible to fix the impl because the trait
definition needs to be changed first (and that may be out of your
control). In that case, for the time being, you can opt out of these
rules by using `#[old_impl_check]` on the impl and adding a
`#![feature(old_impl_check)]` to your crate declaration.
@nikomatsakis
Copy link
Contributor Author

Make check passes locally.

@nikomatsakis
Copy link
Contributor Author

Giving p=1 because this should land for alpha, but it's not supercritical.

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 7, 2015
Conflicts:
	src/libcollections/lib.rs
	src/librustc/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
@alexcrichton alexcrichton merged commit d31105e into rust-lang:master Jan 7, 2015
@nikomatsakis nikomatsakis deleted the unused-tps-in-impl branch March 30, 2016 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants