-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suggestions to
extra_unused_type_parameters
- Loading branch information
1 parent
1d1e723
commit 894a6a6
Showing
8 changed files
with
306 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
avoid-breaking-exported-api = true |
9 changes: 9 additions & 0 deletions
9
tests/ui-toml/extra_unused_type_parameters/extra_unused_type_parameters.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub struct S; | ||
|
||
impl S { | ||
pub fn exported_fn<T>() { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused, clippy::needless_lifetimes)] | ||
#![warn(clippy::extra_unused_type_parameters)] | ||
|
||
fn unused_ty(x: u8) { | ||
unimplemented!() | ||
} | ||
|
||
fn unused_multi(x: u8) { | ||
unimplemented!() | ||
} | ||
|
||
fn unused_with_lt<'a>(x: &'a u8) { | ||
unimplemented!() | ||
} | ||
|
||
fn used_ty<T>(x: T, y: u8) {} | ||
|
||
fn used_ref<'a, T>(x: &'a T) {} | ||
|
||
fn used_ret<T: Default>(x: u8) -> T { | ||
T::default() | ||
} | ||
|
||
fn unused_bounded<U>(x: U) { | ||
unimplemented!(); | ||
} | ||
|
||
fn some_unused<B, C>(b: B, c: C) { | ||
unimplemented!(); | ||
} | ||
|
||
fn used_opaque<A>(iter: impl Iterator<Item = A>) -> usize { | ||
iter.count() | ||
} | ||
|
||
fn used_ret_opaque<A>() -> impl Iterator<Item = A> { | ||
std::iter::empty() | ||
} | ||
|
||
fn used_vec_box<T>(x: Vec<Box<T>>) {} | ||
|
||
fn used_body<T: Default + ToString>() -> String { | ||
T::default().to_string() | ||
} | ||
|
||
fn used_closure<T: Default + ToString>() -> impl Fn() { | ||
|| println!("{}", T::default().to_string()) | ||
} | ||
|
||
struct S; | ||
|
||
impl S { | ||
fn unused_ty_impl(&self) { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
// Don't lint on trait methods | ||
trait Foo { | ||
fn bar<T>(&self); | ||
} | ||
|
||
impl Foo for S { | ||
fn bar<T>(&self) {} | ||
} | ||
|
||
fn skip_index<A, Iter>(iter: Iter, index: usize) -> impl Iterator<Item = A> | ||
where | ||
Iter: Iterator<Item = A>, | ||
{ | ||
iter.enumerate() | ||
.filter_map(move |(i, a)| if i == index { None } else { Some(a) }) | ||
} | ||
|
||
fn unused_opaque(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>() { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
mod issue10319 { | ||
fn assert_send<T: Send>() {} | ||
|
||
fn assert_send_where<T>() | ||
where | ||
T: Send, | ||
{ | ||
} | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.