Tests pass

This commit is contained in:
blyxyas 2023-01-13 12:54:51 +01:00
parent 6c9983b936
commit bdf4fd3e82
No known key found for this signature in database
GPG Key ID: 4D38170B5A2FC334
4 changed files with 17 additions and 15 deletions

View File

@ -344,7 +344,7 @@ declare_clippy_lint! {
/// Use instead:
/// ```rust
/// trait MyTrait {}
/// fn foo<T: A>(a: A) {
/// fn foo<T: MyTrait>(a: T) {
/// // [...]
/// }
/// ```

View File

@ -1,5 +1,5 @@
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:20:14
--> $DIR/borrow_box.rs:24:14
|
LL | let foo: &Box<bool>;
| ^^^^^^^^^^ help: try: `&bool`
@ -11,55 +11,55 @@ LL | #![deny(clippy::borrowed_box)]
| ^^^^^^^^^^^^^^^^^^^^
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:24:10
--> $DIR/borrow_box.rs:28:10
|
LL | foo: &'a Box<bool>,
| ^^^^^^^^^^^^^ help: try: `&'a bool`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:28:17
--> $DIR/borrow_box.rs:32:17
|
LL | fn test4(a: &Box<bool>);
| ^^^^^^^^^^ help: try: `&bool`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:94:25
--> $DIR/borrow_box.rs:98:25
|
LL | pub fn test14(_display: &Box<dyn Display>) {}
| ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:95:25
--> $DIR/borrow_box.rs:99:25
|
LL | pub fn test15(_display: &Box<dyn Display + Send>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:96:29
--> $DIR/borrow_box.rs:100:29
|
LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:98:25
--> $DIR/borrow_box.rs:102:25
|
LL | pub fn test17(_display: &Box<impl Display>) {}
| ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:99:25
--> $DIR/borrow_box.rs:103:25
|
LL | pub fn test18(_display: &Box<impl Display + Send>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:100:29
--> $DIR/borrow_box.rs:104:29
|
LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:105:25
--> $DIR/borrow_box.rs:109:25
|
LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`

View File

@ -2,14 +2,16 @@
#![warn(clippy::impl_trait_in_params)]
pub trait Trait {}
pub trait AnotherTrait<T> {}
// Should warn
pub fn a(_: impl Trait) {}
pub fn c<C: Trait>(_: C, _: impl Trait) {}
fn d(_: impl AnotherTrait<u32>) {}
// Shouldn't warn
pub fn b<B: Trait>(_: B) {}
fn d<D: Trait>(_: D, _: impl Trait) {}
fn e<T: AnotherTrait<u32>>(_: T) {}
fn main() {}

View File

@ -1,17 +1,17 @@
error: 'impl Trait' in the function's parameters
--> $DIR/impl_trait_param.rs:7:13
--> $DIR/impl_trait_in_params.rs:8:13
|
LL | pub fn a(_: impl Trait) {}
| ^^^^^^^^^^
|
= note: `-D clippy::impl-trait-param` implied by `-D warnings`
= note: `-D clippy::impl-trait-in-params` implied by `-D warnings`
help: create a generic type here and replace that 'impl Trait' with `T`
|
LL | pub fn a<T: Trait>(_: impl Trait) {}
| ++++++++++
error: 'impl Trait' in the function's parameters
--> $DIR/impl_trait_param.rs:8:29
--> $DIR/impl_trait_in_params.rs:9:29
|
LL | pub fn c<C: Trait>(_: C, _: impl Trait) {}
| ^^^^^^^^^^