Auto merge of #6035 - matthiaskrgr:try_into_show_type, r=flip1995
useless_conversion: show type in error message. changelog: useless_conversion: show type in error message.
This commit is contained in:
commit
231444d989
@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
|||||||
cx,
|
cx,
|
||||||
USELESS_CONVERSION,
|
USELESS_CONVERSION,
|
||||||
e.span,
|
e.span,
|
||||||
"useless conversion to the same type",
|
&format!("useless conversion to the same type: `{}`", b),
|
||||||
"consider removing `.into()`",
|
"consider removing `.into()`",
|
||||||
sugg,
|
sugg,
|
||||||
Applicability::MachineApplicable, // snippet
|
Applicability::MachineApplicable, // snippet
|
||||||
@ -95,7 +95,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
|||||||
cx,
|
cx,
|
||||||
USELESS_CONVERSION,
|
USELESS_CONVERSION,
|
||||||
e.span,
|
e.span,
|
||||||
"useless conversion to the same type",
|
&format!("useless conversion to the same type: `{}`", b),
|
||||||
"consider removing `.into_iter()`",
|
"consider removing `.into_iter()`",
|
||||||
sugg,
|
sugg,
|
||||||
Applicability::MachineApplicable, // snippet
|
Applicability::MachineApplicable, // snippet
|
||||||
@ -116,7 +116,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
|||||||
cx,
|
cx,
|
||||||
USELESS_CONVERSION,
|
USELESS_CONVERSION,
|
||||||
e.span,
|
e.span,
|
||||||
"useless conversion to the same type",
|
&format!("useless conversion to the same type: `{}`", b),
|
||||||
None,
|
None,
|
||||||
"consider removing `.try_into()`",
|
"consider removing `.try_into()`",
|
||||||
);
|
);
|
||||||
@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
|||||||
cx,
|
cx,
|
||||||
USELESS_CONVERSION,
|
USELESS_CONVERSION,
|
||||||
e.span,
|
e.span,
|
||||||
"useless conversion to the same type",
|
&format!("useless conversion to the same type: `{}`", b),
|
||||||
None,
|
None,
|
||||||
&hint,
|
&hint,
|
||||||
);
|
);
|
||||||
@ -166,7 +166,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
|||||||
cx,
|
cx,
|
||||||
USELESS_CONVERSION,
|
USELESS_CONVERSION,
|
||||||
e.span,
|
e.span,
|
||||||
"useless conversion to the same type",
|
&format!("useless conversion to the same type: `{}`", b),
|
||||||
&sugg_msg,
|
&sugg_msg,
|
||||||
sugg.to_string(),
|
sugg.to_string(),
|
||||||
Applicability::MachineApplicable, // snippet
|
Applicability::MachineApplicable, // snippet
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `T`
|
||||||
--> $DIR/useless_conversion.rs:6:13
|
--> $DIR/useless_conversion.rs:6:13
|
||||||
|
|
|
|
||||||
LL | let _ = T::from(val);
|
LL | let _ = T::from(val);
|
||||||
@ -10,61 +10,61 @@ note: the lint level is defined here
|
|||||||
LL | #![deny(clippy::useless_conversion)]
|
LL | #![deny(clippy::useless_conversion)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `T`
|
||||||
--> $DIR/useless_conversion.rs:7:5
|
--> $DIR/useless_conversion.rs:7:5
|
||||||
|
|
|
|
||||||
LL | val.into()
|
LL | val.into()
|
||||||
| ^^^^^^^^^^ help: consider removing `.into()`: `val`
|
| ^^^^^^^^^^ help: consider removing `.into()`: `val`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `i32`
|
||||||
--> $DIR/useless_conversion.rs:19:22
|
--> $DIR/useless_conversion.rs:19:22
|
||||||
|
|
|
|
||||||
LL | let _: i32 = 0i32.into();
|
LL | let _: i32 = 0i32.into();
|
||||||
| ^^^^^^^^^^^ help: consider removing `.into()`: `0i32`
|
| ^^^^^^^^^^^ help: consider removing `.into()`: `0i32`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion.rs:60:21
|
--> $DIR/useless_conversion.rs:60:21
|
||||||
|
|
|
|
||||||
LL | let _: String = "foo".to_string().into();
|
LL | let _: String = "foo".to_string().into();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion.rs:61:21
|
--> $DIR/useless_conversion.rs:61:21
|
||||||
|
|
|
|
||||||
LL | let _: String = From::from("foo".to_string());
|
LL | let _: String = From::from("foo".to_string());
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion.rs:62:13
|
--> $DIR/useless_conversion.rs:62:13
|
||||||
|
|
|
|
||||||
LL | let _ = String::from("foo".to_string());
|
LL | let _ = String::from("foo".to_string());
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion.rs:63:13
|
--> $DIR/useless_conversion.rs:63:13
|
||||||
|
|
|
|
||||||
LL | let _ = String::from(format!("A: {:04}", 123));
|
LL | let _ = String::from(format!("A: {:04}", 123));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::str::Lines`
|
||||||
--> $DIR/useless_conversion.rs:64:13
|
--> $DIR/useless_conversion.rs:64:13
|
||||||
|
|
|
|
||||||
LL | let _ = "".lines().into_iter();
|
LL | let _ = "".lines().into_iter();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()`
|
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::vec::IntoIter<i32>`
|
||||||
--> $DIR/useless_conversion.rs:65:13
|
--> $DIR/useless_conversion.rs:65:13
|
||||||
|
|
|
|
||||||
LL | let _ = vec![1, 2, 3].into_iter().into_iter();
|
LL | let _ = vec![1, 2, 3].into_iter().into_iter();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion.rs:66:21
|
--> $DIR/useless_conversion.rs:66:21
|
||||||
|
|
|
|
||||||
LL | let _: String = format!("Hello {}", "world").into();
|
LL | let _: String = format!("Hello {}", "world").into();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `i32`
|
||||||
--> $DIR/useless_conversion.rs:71:13
|
--> $DIR/useless_conversion.rs:71:13
|
||||||
|
|
|
|
||||||
LL | let _ = i32::from(a + b) * 3;
|
LL | let _ = i32::from(a + b) * 3;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `T`
|
||||||
--> $DIR/useless_conversion_try.rs:6:13
|
--> $DIR/useless_conversion_try.rs:6:13
|
||||||
|
|
|
|
||||||
LL | let _ = T::try_from(val).unwrap();
|
LL | let _ = T::try_from(val).unwrap();
|
||||||
@ -11,7 +11,7 @@ LL | #![deny(clippy::useless_conversion)]
|
|||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= help: consider removing `T::try_from()`
|
= help: consider removing `T::try_from()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `T`
|
||||||
--> $DIR/useless_conversion_try.rs:7:5
|
--> $DIR/useless_conversion_try.rs:7:5
|
||||||
|
|
|
|
||||||
LL | val.try_into().unwrap()
|
LL | val.try_into().unwrap()
|
||||||
@ -19,7 +19,7 @@ LL | val.try_into().unwrap()
|
|||||||
|
|
|
|
||||||
= help: consider removing `.try_into()`
|
= help: consider removing `.try_into()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion_try.rs:29:21
|
--> $DIR/useless_conversion_try.rs:29:21
|
||||||
|
|
|
|
||||||
LL | let _: String = "foo".to_string().try_into().unwrap();
|
LL | let _: String = "foo".to_string().try_into().unwrap();
|
||||||
@ -27,7 +27,7 @@ LL | let _: String = "foo".to_string().try_into().unwrap();
|
|||||||
|
|
|
|
||||||
= help: consider removing `.try_into()`
|
= help: consider removing `.try_into()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion_try.rs:30:21
|
--> $DIR/useless_conversion_try.rs:30:21
|
||||||
|
|
|
|
||||||
LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap();
|
LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap();
|
||||||
@ -35,7 +35,7 @@ LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap();
|
|||||||
|
|
|
|
||||||
= help: consider removing `TryFrom::try_from()`
|
= help: consider removing `TryFrom::try_from()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion_try.rs:31:13
|
--> $DIR/useless_conversion_try.rs:31:13
|
||||||
|
|
|
|
||||||
LL | let _ = String::try_from("foo".to_string()).unwrap();
|
LL | let _ = String::try_from("foo".to_string()).unwrap();
|
||||||
@ -43,7 +43,7 @@ LL | let _ = String::try_from("foo".to_string()).unwrap();
|
|||||||
|
|
|
|
||||||
= help: consider removing `String::try_from()`
|
= help: consider removing `String::try_from()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion_try.rs:32:13
|
--> $DIR/useless_conversion_try.rs:32:13
|
||||||
|
|
|
|
||||||
LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap();
|
LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap();
|
||||||
@ -51,7 +51,7 @@ LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap();
|
|||||||
|
|
|
|
||||||
= help: consider removing `String::try_from()`
|
= help: consider removing `String::try_from()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion_try.rs:33:21
|
--> $DIR/useless_conversion_try.rs:33:21
|
||||||
|
|
|
|
||||||
LL | let _: String = format!("Hello {}", "world").try_into().unwrap();
|
LL | let _: String = format!("Hello {}", "world").try_into().unwrap();
|
||||||
@ -59,7 +59,7 @@ LL | let _: String = format!("Hello {}", "world").try_into().unwrap();
|
|||||||
|
|
|
|
||||||
= help: consider removing `.try_into()`
|
= help: consider removing `.try_into()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion_try.rs:34:21
|
--> $DIR/useless_conversion_try.rs:34:21
|
||||||
|
|
|
|
||||||
LL | let _: String = "".to_owned().try_into().unwrap();
|
LL | let _: String = "".to_owned().try_into().unwrap();
|
||||||
@ -67,7 +67,7 @@ LL | let _: String = "".to_owned().try_into().unwrap();
|
|||||||
|
|
|
|
||||||
= help: consider removing `.try_into()`
|
= help: consider removing `.try_into()`
|
||||||
|
|
||||||
error: useless conversion to the same type
|
error: useless conversion to the same type: `std::string::String`
|
||||||
--> $DIR/useless_conversion_try.rs:35:27
|
--> $DIR/useless_conversion_try.rs:35:27
|
||||||
|
|
|
|
||||||
LL | let _: String = match String::from("_").try_into() {
|
LL | let _: String = match String::from("_").try_into() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user