1
Fork 0

fix failing tests

This commit is contained in:
Icxolu 2023-05-03 20:07:02 +02:00
parent 8701009860
commit 4ed7fd1ecc
9 changed files with 26 additions and 24 deletions

View file

@ -1,5 +1,6 @@
//@run-rustfix //@run-rustfix
#![warn(clippy::box_default)] #![warn(clippy::box_default)]
#![allow(clippy::default_constructed_unit_structs)]
#[derive(Default)] #[derive(Default)]
struct ImplementsDefault; struct ImplementsDefault;

View file

@ -1,5 +1,6 @@
//@run-rustfix //@run-rustfix
#![warn(clippy::box_default)] #![warn(clippy::box_default)]
#![allow(clippy::default_constructed_unit_structs)]
#[derive(Default)] #[derive(Default)]
struct ImplementsDefault; struct ImplementsDefault;

View file

@ -1,5 +1,5 @@
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:22:32 --> $DIR/box_default.rs:23:32
| |
LL | let _string: Box<String> = Box::new(Default::default()); LL | let _string: Box<String> = Box::new(Default::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
@ -7,91 +7,91 @@ LL | let _string: Box<String> = Box::new(Default::default());
= note: `-D clippy::box-default` implied by `-D warnings` = note: `-D clippy::box-default` implied by `-D warnings`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:23:17 --> $DIR/box_default.rs:24:17
| |
LL | let _byte = Box::new(u8::default()); LL | let _byte = Box::new(u8::default());
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<u8>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<u8>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:24:16 --> $DIR/box_default.rs:25:16
| |
LL | let _vec = Box::new(Vec::<u8>::new()); LL | let _vec = Box::new(Vec::<u8>::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Vec<u8>>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Vec<u8>>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:25:17 --> $DIR/box_default.rs:26:17
| |
LL | let _impl = Box::new(ImplementsDefault::default()); LL | let _impl = Box::new(ImplementsDefault::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:26:18 --> $DIR/box_default.rs:27:18
| |
LL | let _impl2 = Box::new(<ImplementsDefault as Default>::default()); LL | let _impl2 = Box::new(<ImplementsDefault as Default>::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:27:42 --> $DIR/box_default.rs:28:42
| |
LL | let _impl3: Box<ImplementsDefault> = Box::new(Default::default()); LL | let _impl3: Box<ImplementsDefault> = Box::new(Default::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:29:28 --> $DIR/box_default.rs:30:28
| |
LL | let _in_macro = outer!(Box::new(String::new())); LL | let _in_macro = outer!(Box::new(String::new()));
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<String>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<String>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:30:34 --> $DIR/box_default.rs:31:34
| |
LL | let _string_default = outer!(Box::new(String::from(""))); LL | let _string_default = outer!(Box::new(String::from("")));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<String>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<String>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:31:46 --> $DIR/box_default.rs:32:46
| |
LL | let _vec2: Box<Vec<ImplementsDefault>> = Box::new(vec![]); LL | let _vec2: Box<Vec<ImplementsDefault>> = Box::new(vec![]);
| ^^^^^^^^^^^^^^^^ help: try: `Box::default()` | ^^^^^^^^^^^^^^^^ help: try: `Box::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:32:33 --> $DIR/box_default.rs:33:33
| |
LL | let _vec3: Box<Vec<bool>> = Box::new(Vec::from([])); LL | let _vec3: Box<Vec<bool>> = Box::new(Vec::from([]));
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:33:25 --> $DIR/box_default.rs:34:25
| |
LL | let _vec4: Box<_> = Box::new(Vec::from([false; 0])); LL | let _vec4: Box<_> = Box::new(Vec::from([false; 0]));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Vec<bool>>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Vec<bool>>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:35:16 --> $DIR/box_default.rs:36:16
| |
LL | call_ty_fn(Box::new(u8::default())); LL | call_ty_fn(Box::new(u8::default()));
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:40:5 --> $DIR/box_default.rs:41:5
| |
LL | Box::new(bool::default()) LL | Box::new(bool::default())
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<bool>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<bool>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:57:28 --> $DIR/box_default.rs:58:28
| |
LL | let _: Box<dyn Read> = Box::new(ImplementsDefault::default()); LL | let _: Box<dyn Read> = Box::new(ImplementsDefault::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:66:17 --> $DIR/box_default.rs:67:17
| |
LL | let _ = Box::new(WeirdPathed::default()); LL | let _ = Box::new(WeirdPathed::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<WeirdPathed>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<WeirdPathed>::default()`
error: `Box::new(_)` of default value error: `Box::new(_)` of default value
--> $DIR/box_default.rs:78:18 --> $DIR/box_default.rs:79:18
| |
LL | Some(Box::new(Foo::default())) LL | Some(Box::new(Foo::default()))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Foo>::default()` | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Foo>::default()`

View file

@ -32,7 +32,7 @@ struct SelfKeywords;
impl From<X> for SelfKeywords { impl From<X> for SelfKeywords {
fn from(val: X) -> Self { fn from(val: X) -> Self {
let _ = X::default(); let _ = X;
let _ = X::FOO; let _ = X::FOO;
let _: X = val; let _: X = val;

View file

@ -32,7 +32,7 @@ struct SelfKeywords;
impl Into<SelfKeywords> for X { impl Into<SelfKeywords> for X {
fn into(self) -> SelfKeywords { fn into(self) -> SelfKeywords {
let _ = Self::default(); let _ = Self;
let _ = Self::FOO; let _ = Self::FOO;
let _: Self = self; let _: Self = self;

View file

@ -35,7 +35,7 @@ help: replace the `Into` implementation with `From<X>`
| |
LL ~ impl From<X> for SelfKeywords { LL ~ impl From<X> for SelfKeywords {
LL ~ fn from(val: X) -> Self { LL ~ fn from(val: X) -> Self {
LL ~ let _ = X::default(); LL ~ let _ = X;
LL ~ let _ = X::FOO; LL ~ let _ = X::FOO;
LL ~ let _: X = val; LL ~ let _: X = val;
| |

View file

@ -33,7 +33,7 @@ impl SelfTrait for Bad {
fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {} fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {}
fn vals(_: Self) -> Self { fn vals(_: Self) -> Self {
Self::default() Self
} }
} }
@ -70,7 +70,7 @@ impl SelfTrait for Good {
fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {} fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {}
fn vals(_: Self) -> Self { fn vals(_: Self) -> Self {
Self::default() Self
} }
} }

View file

@ -33,7 +33,7 @@ impl SelfTrait for Bad {
fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {} fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {}
fn vals(_: Bad) -> Bad { fn vals(_: Bad) -> Bad {
Bad::default() Bad
} }
} }
@ -70,7 +70,7 @@ impl SelfTrait for Good {
fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {} fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {}
fn vals(_: Self) -> Self { fn vals(_: Self) -> Self {
Self::default() Self
} }
} }

View file

@ -63,7 +63,7 @@ LL | fn vals(_: Bad) -> Bad {
error: unnecessary structure name repetition error: unnecessary structure name repetition
--> $DIR/use_self_trait.rs:36:9 --> $DIR/use_self_trait.rs:36:9
| |
LL | Bad::default() LL | Bad
| ^^^ help: use the applicable keyword: `Self` | ^^^ help: use the applicable keyword: `Self`
error: unnecessary structure name repetition error: unnecessary structure name repetition