Fix tests, only lint for public tests
This commit is contained in:
parent
5ed338dff9
commit
775573768e
8 changed files with 50 additions and 19 deletions
1
tests/ui-toml/impl_trait_in_params/clippy.toml
Normal file
1
tests/ui-toml/impl_trait_in_params/clippy.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
avoid-breaking-exported-api = false
|
||||
16
tests/ui-toml/impl_trait_in_params/impl_trait_in_params.rs
Normal file
16
tests/ui-toml/impl_trait_in_params/impl_trait_in_params.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//! As avoid-breaking-exported-api is `false`, nothing here should lint
|
||||
#![warn(clippy::impl_trait_in_params)]
|
||||
#![no_main]
|
||||
//@no-rustfix
|
||||
|
||||
pub trait Trait {}
|
||||
|
||||
trait Private {
|
||||
fn t(_: impl Trait);
|
||||
fn tt<T: Trait>(_: T);
|
||||
}
|
||||
|
||||
pub trait Public {
|
||||
fn t(_: impl Trait); //~ ERROR: `impl Trait` used as a function parameter
|
||||
fn tt<T: Trait>(_: T);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
error: `impl Trait` used as a function parameter
|
||||
--> $DIR/impl_trait_in_params.rs:14:13
|
||||
|
|
||||
LL | fn t(_: impl Trait);
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::impl-trait-in-params` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::impl_trait_in_params)]`
|
||||
help: add a type parameter
|
||||
|
|
||||
LL | fn t<{ /* Generic name */ }: Trait>(_: impl Trait);
|
||||
| +++++++++++++++++++++++++++++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
avoid-breaking-exported-api = true
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
//! As avoid-breaking-exported-api is `true`, nothing here should lint
|
||||
#![warn(clippy::impl_trait_in_params)]
|
||||
#![no_main]
|
||||
|
||||
trait Trait {}
|
||||
|
||||
trait T {
|
||||
fn t(_: impl Trait);
|
||||
fn tt<T: Trait>(_: T);
|
||||
}
|
||||
|
|
@ -19,8 +19,14 @@ fn d(_: impl AnotherTrait<u32>) {}
|
|||
|
||||
//------ IMPLS
|
||||
|
||||
trait T {
|
||||
// See test in ui-toml for a case where avoid-breaking-exported-api is set to true
|
||||
pub trait Public {
|
||||
// See test in ui-toml for a case where avoid-breaking-exported-api is set to false
|
||||
fn t(_: impl Trait);
|
||||
fn tt<T: Trait>(_: T) {}
|
||||
}
|
||||
|
||||
trait Private {
|
||||
// This shouldn't lint
|
||||
fn t(_: impl Trait);
|
||||
fn tt<T: Trait>(_: T) {}
|
||||
}
|
||||
|
|
@ -34,7 +40,7 @@ impl S {
|
|||
}
|
||||
|
||||
// Trying with traits
|
||||
impl T for S {
|
||||
impl Public for S {
|
||||
fn t(_: impl Trait) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ LL | pub fn c<C: Trait, { /* Generic name */ }: Trait>(_: C, _: impl Trait) {}
|
|||
| +++++++++++++++++++++++++++++++
|
||||
|
||||
error: `impl Trait` used as a function parameter
|
||||
--> $DIR/impl_trait_in_params.rs:30:17
|
||||
--> $DIR/impl_trait_in_params.rs:36:17
|
||||
|
|
||||
LL | pub fn h(_: impl Trait) {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -34,7 +34,7 @@ LL | pub fn h<{ /* Generic name */ }: Trait>(_: impl Trait) {}
|
|||
| +++++++++++++++++++++++++++++++
|
||||
|
||||
error: `impl Trait` used as a function parameter
|
||||
--> $DIR/impl_trait_in_params.rs:33:45
|
||||
--> $DIR/impl_trait_in_params.rs:39:45
|
||||
|
|
||||
LL | pub fn k<K: AnotherTrait<u32>>(_: K, _: impl AnotherTrait<u32>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue