Skip to content

Commit 4ed7fd1

Browse files
committed
fix failing tests
1 parent 8701009 commit 4ed7fd1

9 files changed

+26
-24
lines changed

tests/ui/box_default.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@run-rustfix
22
#![warn(clippy::box_default)]
3+
#![allow(clippy::default_constructed_unit_structs)]
34

45
#[derive(Default)]
56
struct ImplementsDefault;

tests/ui/box_default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@run-rustfix
22
#![warn(clippy::box_default)]
3+
#![allow(clippy::default_constructed_unit_structs)]
34

45
#[derive(Default)]
56
struct ImplementsDefault;

tests/ui/box_default.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,97 @@
11
error: `Box::new(_)` of default value
2-
--> $DIR/box_default.rs:22:32
2+
--> $DIR/box_default.rs:23:32
33
|
44
LL | let _string: Box<String> = Box::new(Default::default());
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
66
|
77
= note: `-D clippy::box-default` implied by `-D warnings`
88

99
error: `Box::new(_)` of default value
10-
--> $DIR/box_default.rs:23:17
10+
--> $DIR/box_default.rs:24:17
1111
|
1212
LL | let _byte = Box::new(u8::default());
1313
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<u8>::default()`
1414

1515
error: `Box::new(_)` of default value
16-
--> $DIR/box_default.rs:24:16
16+
--> $DIR/box_default.rs:25:16
1717
|
1818
LL | let _vec = Box::new(Vec::<u8>::new());
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Vec<u8>>::default()`
2020

2121
error: `Box::new(_)` of default value
22-
--> $DIR/box_default.rs:25:17
22+
--> $DIR/box_default.rs:26:17
2323
|
2424
LL | let _impl = Box::new(ImplementsDefault::default());
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
2626

2727
error: `Box::new(_)` of default value
28-
--> $DIR/box_default.rs:26:18
28+
--> $DIR/box_default.rs:27:18
2929
|
3030
LL | let _impl2 = Box::new(<ImplementsDefault as Default>::default());
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
3232

3333
error: `Box::new(_)` of default value
34-
--> $DIR/box_default.rs:27:42
34+
--> $DIR/box_default.rs:28:42
3535
|
3636
LL | let _impl3: Box<ImplementsDefault> = Box::new(Default::default());
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
3838

3939
error: `Box::new(_)` of default value
40-
--> $DIR/box_default.rs:29:28
40+
--> $DIR/box_default.rs:30:28
4141
|
4242
LL | let _in_macro = outer!(Box::new(String::new()));
4343
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<String>::default()`
4444

4545
error: `Box::new(_)` of default value
46-
--> $DIR/box_default.rs:30:34
46+
--> $DIR/box_default.rs:31:34
4747
|
4848
LL | let _string_default = outer!(Box::new(String::from("")));
4949
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<String>::default()`
5050

5151
error: `Box::new(_)` of default value
52-
--> $DIR/box_default.rs:31:46
52+
--> $DIR/box_default.rs:32:46
5353
|
5454
LL | let _vec2: Box<Vec<ImplementsDefault>> = Box::new(vec![]);
5555
| ^^^^^^^^^^^^^^^^ help: try: `Box::default()`
5656

5757
error: `Box::new(_)` of default value
58-
--> $DIR/box_default.rs:32:33
58+
--> $DIR/box_default.rs:33:33
5959
|
6060
LL | let _vec3: Box<Vec<bool>> = Box::new(Vec::from([]));
6161
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
6262

6363
error: `Box::new(_)` of default value
64-
--> $DIR/box_default.rs:33:25
64+
--> $DIR/box_default.rs:34:25
6565
|
6666
LL | let _vec4: Box<_> = Box::new(Vec::from([false; 0]));
6767
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Vec<bool>>::default()`
6868

6969
error: `Box::new(_)` of default value
70-
--> $DIR/box_default.rs:35:16
70+
--> $DIR/box_default.rs:36:16
7171
|
7272
LL | call_ty_fn(Box::new(u8::default()));
7373
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
7474

7575
error: `Box::new(_)` of default value
76-
--> $DIR/box_default.rs:40:5
76+
--> $DIR/box_default.rs:41:5
7777
|
7878
LL | Box::new(bool::default())
7979
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<bool>::default()`
8080

8181
error: `Box::new(_)` of default value
82-
--> $DIR/box_default.rs:57:28
82+
--> $DIR/box_default.rs:58:28
8383
|
8484
LL | let _: Box<dyn Read> = Box::new(ImplementsDefault::default());
8585
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
8686

8787
error: `Box::new(_)` of default value
88-
--> $DIR/box_default.rs:66:17
88+
--> $DIR/box_default.rs:67:17
8989
|
9090
LL | let _ = Box::new(WeirdPathed::default());
9191
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<WeirdPathed>::default()`
9292

9393
error: `Box::new(_)` of default value
94-
--> $DIR/box_default.rs:78:18
94+
--> $DIR/box_default.rs:79:18
9595
|
9696
LL | Some(Box::new(Foo::default()))
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Foo>::default()`

tests/ui/from_over_into.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct SelfKeywords;
3232

3333
impl From<X> for SelfKeywords {
3434
fn from(val: X) -> Self {
35-
let _ = X::default();
35+
let _ = X;
3636
let _ = X::FOO;
3737
let _: X = val;
3838

tests/ui/from_over_into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct SelfKeywords;
3232

3333
impl Into<SelfKeywords> for X {
3434
fn into(self) -> SelfKeywords {
35-
let _ = Self::default();
35+
let _ = Self;
3636
let _ = Self::FOO;
3737
let _: Self = self;
3838

tests/ui/from_over_into.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ help: replace the `Into` implementation with `From<X>`
3535
|
3636
LL ~ impl From<X> for SelfKeywords {
3737
LL ~ fn from(val: X) -> Self {
38-
LL ~ let _ = X::default();
38+
LL ~ let _ = X;
3939
LL ~ let _ = X::FOO;
4040
LL ~ let _: X = val;
4141
|

tests/ui/use_self_trait.fixed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl SelfTrait for Bad {
3333
fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {}
3434

3535
fn vals(_: Self) -> Self {
36-
Self::default()
36+
Self
3737
}
3838
}
3939

@@ -70,7 +70,7 @@ impl SelfTrait for Good {
7070
fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {}
7171

7272
fn vals(_: Self) -> Self {
73-
Self::default()
73+
Self
7474
}
7575
}
7676

tests/ui/use_self_trait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl SelfTrait for Bad {
3333
fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {}
3434

3535
fn vals(_: Bad) -> Bad {
36-
Bad::default()
36+
Bad
3737
}
3838
}
3939

@@ -70,7 +70,7 @@ impl SelfTrait for Good {
7070
fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {}
7171

7272
fn vals(_: Self) -> Self {
73-
Self::default()
73+
Self
7474
}
7575
}
7676

tests/ui/use_self_trait.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ LL | fn vals(_: Bad) -> Bad {
6363
error: unnecessary structure name repetition
6464
--> $DIR/use_self_trait.rs:36:9
6565
|
66-
LL | Bad::default()
66+
LL | Bad
6767
| ^^^ help: use the applicable keyword: `Self`
6868

6969
error: unnecessary structure name repetition

0 commit comments

Comments
 (0)