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

Should have lint to disallow unused type parameters #25871

Closed
lambda opened this issue May 29, 2015 · 4 comments
Closed

Should have lint to disallow unused type parameters #25871

lambda opened this issue May 29, 2015 · 4 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@lambda
Copy link
Contributor

lambda commented May 29, 2015

The following compiles and runs without warning:

fn foo<T: Sync> () { }

fn main() {
    foo::<i32>()
}

I think that this should at least warn, just like unused imports or unused variables; it would almost always be a result from a mistake in refactoring.

@oli-obk
Copy link
Contributor

oli-obk commented May 29, 2015

Note: types already report an error here:

struct X<T> {
    x: i32,
}

fn main() {}
<anon>:1:10: 1:11 error: parameter `T` is never used
<anon>:1 struct X<T> {
                  ^
<anon>:1:10: 1:11 help: consider removing `T` or using a marker such as `core::marker::PhantomData`

@steveklabnik steveklabnik added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels May 29, 2015
@shepmaster
Copy link
Member

Dupe of #18549 ?

@sanxiyn
Copy link
Member

sanxiyn commented Jul 1, 2015

I implemented this in #26684, and there is a question whether the lint should warn-by-default. You may want to comment.

@steveklabnik
Copy link
Member

Since new lints have a big impact on users of rustc, the policy is that they should go through the RFC process like other user-facing changes. As such, I'm going to give this one a close, but if anyone comes across this ticket and wants this lint, consider adding it to clippy and/or writing up an RFC. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants