mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 04:26:48 +00:00
fix failing tests
This commit is contained in:
parent
8701009860
commit
4ed7fd1ecc
@ -1,5 +1,6 @@
|
||||
//@run-rustfix
|
||||
#![warn(clippy::box_default)]
|
||||
#![allow(clippy::default_constructed_unit_structs)]
|
||||
|
||||
#[derive(Default)]
|
||||
struct ImplementsDefault;
|
||||
|
@ -1,5 +1,6 @@
|
||||
//@run-rustfix
|
||||
#![warn(clippy::box_default)]
|
||||
#![allow(clippy::default_constructed_unit_structs)]
|
||||
|
||||
#[derive(Default)]
|
||||
struct ImplementsDefault;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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`
|
||||
|
||||
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());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<u8>::default()`
|
||||
|
||||
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());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Vec<u8>>::default()`
|
||||
|
||||
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());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
|
||||
|
||||
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());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
|
||||
|
||||
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());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
|
||||
|
||||
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()));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<String>::default()`
|
||||
|
||||
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("")));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<String>::default()`
|
||||
|
||||
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![]);
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `Box::default()`
|
||||
|
||||
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([]));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
|
||||
|
||||
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]));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Vec<bool>>::default()`
|
||||
|
||||
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()));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()`
|
||||
|
||||
error: `Box::new(_)` of default value
|
||||
--> $DIR/box_default.rs:40:5
|
||||
--> $DIR/box_default.rs:41:5
|
||||
|
|
||||
LL | Box::new(bool::default())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<bool>::default()`
|
||||
|
||||
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());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
|
||||
|
||||
error: `Box::new(_)` of default value
|
||||
--> $DIR/box_default.rs:66:17
|
||||
--> $DIR/box_default.rs:67:17
|
||||
|
|
||||
LL | let _ = Box::new(WeirdPathed::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<WeirdPathed>::default()`
|
||||
|
||||
error: `Box::new(_)` of default value
|
||||
--> $DIR/box_default.rs:78:18
|
||||
--> $DIR/box_default.rs:79:18
|
||||
|
|
||||
LL | Some(Box::new(Foo::default()))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<Foo>::default()`
|
||||
|
@ -32,7 +32,7 @@ struct SelfKeywords;
|
||||
|
||||
impl From<X> for SelfKeywords {
|
||||
fn from(val: X) -> Self {
|
||||
let _ = X::default();
|
||||
let _ = X;
|
||||
let _ = X::FOO;
|
||||
let _: X = val;
|
||||
|
||||
|
@ -32,7 +32,7 @@ struct SelfKeywords;
|
||||
|
||||
impl Into<SelfKeywords> for X {
|
||||
fn into(self) -> SelfKeywords {
|
||||
let _ = Self::default();
|
||||
let _ = Self;
|
||||
let _ = Self::FOO;
|
||||
let _: Self = self;
|
||||
|
||||
|
@ -35,7 +35,7 @@ help: replace the `Into` implementation with `From<X>`
|
||||
|
|
||||
LL ~ impl From<X> for SelfKeywords {
|
||||
LL ~ fn from(val: X) -> Self {
|
||||
LL ~ let _ = X::default();
|
||||
LL ~ let _ = X;
|
||||
LL ~ let _ = X::FOO;
|
||||
LL ~ let _: X = val;
|
||||
|
|
||||
|
@ -33,7 +33,7 @@ impl SelfTrait for Bad {
|
||||
fn nested(_p1: Box<Self>, _p2: (&u8, &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 vals(_: Self) -> Self {
|
||||
Self::default()
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ impl SelfTrait for Bad {
|
||||
fn nested(_p1: Box<Bad>, _p2: (&u8, &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 vals(_: Self) -> Self {
|
||||
Self::default()
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ LL | fn vals(_: Bad) -> Bad {
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self_trait.rs:36:9
|
||||
|
|
||||
LL | Bad::default()
|
||||
LL | Bad
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
|
Loading…
Reference in New Issue
Block a user