Fix tests, only lint for public tests

This commit is contained in:
blyxyas 2023-09-23 20:36:06 +02:00
parent 5ed338dff9
commit 775573768e
No known key found for this signature in database
GPG key ID: 11095C6C8A0C9137
8 changed files with 50 additions and 19 deletions

View file

@ -0,0 +1 @@
avoid-breaking-exported-api = false

View 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);
}

View file

@ -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

View file

@ -1 +0,0 @@
avoid-breaking-exported-api = true

View file

@ -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);
}

View file

@ -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) {}
}

View file

@ -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>) {}
| ^^^^^^^^^^^^^^^^^^^^^^