-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix more false positives for extra_unused_type_parameters
#10392
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
#![allow(unused, clippy::needless_lifetimes)] | ||
#![warn(clippy::extra_unused_type_parameters)] | ||
|
||
fn unused_ty<T>(x: u8) {} | ||
fn unused_ty<T>(x: u8) { | ||
unimplemented!() | ||
} | ||
|
||
fn unused_multi<T, U>(x: u8) {} | ||
fn unused_multi<T, U>(x: u8) { | ||
unimplemented!() | ||
} | ||
|
||
fn unused_with_lt<'a, T>(x: &'a u8) {} | ||
fn unused_with_lt<'a, T>(x: &'a u8) { | ||
unimplemented!() | ||
} | ||
|
||
fn used_ty<T>(x: T, y: u8) {} | ||
|
||
|
@@ -51,7 +57,9 @@ fn used_closure<T: Default + ToString>() -> impl Fn() { | |
struct S; | ||
|
||
impl S { | ||
fn unused_ty_impl<T>(&self) {} | ||
fn unused_ty_impl<T>(&self) { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
// Don't lint on trait methods | ||
|
@@ -71,7 +79,23 @@ where | |
.filter_map(move |(i, a)| if i == index { None } else { Some(a) }) | ||
} | ||
|
||
fn unused_opaque<A, B>(dummy: impl Default) {} | ||
fn unused_opaque<A, B>(dummy: impl Default) { | ||
unimplemented!() | ||
} | ||
|
||
mod unexported_trait_bounds { | ||
mod private { | ||
pub trait Private {} | ||
} | ||
|
||
fn priv_trait_bound<T: private::Private>() { | ||
unimplemented!(); | ||
} | ||
|
||
fn unused_with_priv_trait_bound<T: private::Private, U>() { | ||
unimplemented!(); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I missed it, but I think there is a test for a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can tell, that relies on the config option, right? Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have a look in the |
||
|
||
mod issue10319 { | ||
fn assert_send<T: Send>() {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,75 @@ | ||
error: type parameter goes unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:4:13 | ||
| | ||
LL | fn unused_ty<T>(x: u8) {} | ||
LL | fn unused_ty<T>(x: u8) { | ||
| ^^^ | ||
| | ||
= help: consider removing the parameter | ||
= note: `-D clippy::extra-unused-type-parameters` implied by `-D warnings` | ||
|
||
error: type parameters go unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:6:16 | ||
--> $DIR/extra_unused_type_parameters.rs:8:16 | ||
| | ||
LL | fn unused_multi<T, U>(x: u8) {} | ||
LL | fn unused_multi<T, U>(x: u8) { | ||
| ^^^^^^ | ||
| | ||
= help: consider removing the parameters | ||
|
||
error: type parameter goes unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:8:23 | ||
--> $DIR/extra_unused_type_parameters.rs:12:23 | ||
| | ||
LL | fn unused_with_lt<'a, T>(x: &'a u8) {} | ||
LL | fn unused_with_lt<'a, T>(x: &'a u8) { | ||
| ^ | ||
| | ||
= help: consider removing the parameter | ||
|
||
error: type parameter goes unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:18:19 | ||
--> $DIR/extra_unused_type_parameters.rs:24:19 | ||
| | ||
LL | fn unused_bounded<T: Default, U>(x: U) { | ||
| ^^^^^^^^^^^ | ||
| | ||
= help: consider removing the parameter | ||
|
||
error: type parameter goes unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:22:24 | ||
--> $DIR/extra_unused_type_parameters.rs:28:24 | ||
| | ||
LL | fn unused_where_clause<T, U>(x: U) | ||
| ^^ | ||
| | ||
= help: consider removing the parameter | ||
|
||
error: type parameters go unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:29:16 | ||
--> $DIR/extra_unused_type_parameters.rs:35:16 | ||
| | ||
LL | fn some_unused<A, B, C, D: Iterator<Item = (B, C)>, E>(b: B, c: C) { | ||
| ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ | ||
| | ||
= help: consider removing the parameters | ||
|
||
error: type parameter goes unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:54:22 | ||
--> $DIR/extra_unused_type_parameters.rs:60:22 | ||
| | ||
LL | fn unused_ty_impl<T>(&self) {} | ||
LL | fn unused_ty_impl<T>(&self) { | ||
| ^^^ | ||
| | ||
= help: consider removing the parameter | ||
|
||
error: type parameters go unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:74:17 | ||
--> $DIR/extra_unused_type_parameters.rs:82:17 | ||
| | ||
LL | fn unused_opaque<A, B>(dummy: impl Default) {} | ||
LL | fn unused_opaque<A, B>(dummy: impl Default) { | ||
| ^^^^^^ | ||
| | ||
= help: consider removing the parameters | ||
|
||
error: aborting due to 8 previous errors | ||
error: type parameter goes unused in function definition | ||
--> $DIR/extra_unused_type_parameters.rs:95:58 | ||
| | ||
LL | fn unused_with_priv_trait_bound<T: private::Private, U>() { | ||
| ^ | ||
| | ||
= help: consider removing the parameter | ||
|
||
error: aborting due to 9 previous errors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird function name IMO. But the best thing I can come up with is:
is_exported_macro_or_empty
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, names are hard... I couldn't really come up with anything satisfactory either. Maybe
is_empty_exported_or_macro
is the least ambiguous.