useless_conversion: show type in error message.

changelog: useless_conversion: show type in error message.
This commit is contained in:
Matthias Krüger 2020-09-13 12:42:14 +02:00
parent 21c351867a
commit 7ba1a8fec4
3 changed files with 25 additions and 25 deletions

View file

@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
cx,
USELESS_CONVERSION,
e.span,
"useless conversion to the same type",
&format!("useless conversion to the same type: `{}`", b),
"consider removing `.into()`",
sugg,
Applicability::MachineApplicable, // snippet
@ -95,7 +95,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
cx,
USELESS_CONVERSION,
e.span,
"useless conversion to the same type",
&format!("useless conversion to the same type: `{}`", b),
"consider removing `.into_iter()`",
sugg,
Applicability::MachineApplicable, // snippet
@ -116,7 +116,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
cx,
USELESS_CONVERSION,
e.span,
"useless conversion to the same type",
&format!("useless conversion to the same type: `{}`", b),
None,
"consider removing `.try_into()`",
);
@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
cx,
USELESS_CONVERSION,
e.span,
"useless conversion to the same type",
&format!("useless conversion to the same type: `{}`", b),
None,
&hint,
);
@ -166,7 +166,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
cx,
USELESS_CONVERSION,
e.span,
"useless conversion to the same type",
&format!("useless conversion to the same type: `{}`", b),
&sugg_msg,
sugg.to_string(),
Applicability::MachineApplicable, // snippet

View file

@ -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
|
LL | let _ = T::from(val);
@ -10,61 +10,61 @@ note: the lint level is defined here
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
|
LL | val.into()
| ^^^^^^^^^^ 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
|
LL | let _: i32 = 0i32.into();
| ^^^^^^^^^^^ 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
|
LL | let _: String = "foo".to_string().into();
| ^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
LL | let _: String = 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
|
LL | let _ = 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
|
LL | let _ = 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
|
LL | let _ = "".lines().into_iter();
| ^^^^^^^^^^^^^^^^^^^^^^ 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
|
LL | let _ = vec![1, 2, 3].into_iter().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
|
LL | let _: String = format!("Hello {}", "world").into();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
LL | let _ = i32::from(a + b) * 3;

View file

@ -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
|
LL | let _ = T::try_from(val).unwrap();
@ -11,7 +11,7 @@ LL | #![deny(clippy::useless_conversion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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
|
LL | val.try_into().unwrap()
@ -19,7 +19,7 @@ LL | val.try_into().unwrap()
|
= 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
|
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()`
error: useless conversion to the same type
error: useless conversion to the same type: `std::string::String`
--> $DIR/useless_conversion_try.rs:30:21
|
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()`
error: useless conversion to the same type
error: useless conversion to the same type: `std::string::String`
--> $DIR/useless_conversion_try.rs:31:13
|
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()`
error: useless conversion to the same type
error: useless conversion to the same type: `std::string::String`
--> $DIR/useless_conversion_try.rs:32:13
|
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()`
error: useless conversion to the same type
error: useless conversion to the same type: `std::string::String`
--> $DIR/useless_conversion_try.rs:33:21
|
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()`
error: useless conversion to the same type
error: useless conversion to the same type: `std::string::String`
--> $DIR/useless_conversion_try.rs:34:21
|
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()`
error: useless conversion to the same type
error: useless conversion to the same type: `std::string::String`
--> $DIR/useless_conversion_try.rs:35:27
|
LL | let _: String = match String::from("_").try_into() {