commit
dc5ee5aa19
@ -85,7 +85,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
|
||||
let a = cx.tables.expr_ty(e);
|
||||
let b = cx.tables.expr_ty(&args[0]);
|
||||
if same_tys(cx, a, b) {
|
||||
let sugg = snippet(cx, args[0].span, "<expr>").into_owned();
|
||||
let sugg = snippet(cx, args[0].span.source_callsite(), "<expr>").into_owned();
|
||||
let sugg_msg = format!("consider removing `{}()`", snippet(cx, path.span, "From::from"));
|
||||
span_lint_and_then(cx, IDENTITY_CONVERSION, e.span, "identical conversion", |db| {
|
||||
db.span_suggestion(e.span, &sugg_msg, sugg);
|
||||
|
@ -38,6 +38,7 @@ fn main() {
|
||||
let _: String = "foo".to_string().into();
|
||||
let _: String = From::from("foo".to_string());
|
||||
let _ = String::from("foo".to_string());
|
||||
let _ = String::from(format!("A: {:04}", 123));
|
||||
let _ = "".lines().into_iter();
|
||||
let _ = vec![1, 2, 3].into_iter().into_iter();
|
||||
}
|
||||
|
@ -43,14 +43,20 @@ error: identical conversion
|
||||
error: identical conversion
|
||||
--> $DIR/identity_conversion.rs:41:13
|
||||
|
|
||||
41 | let _ = "".lines().into_iter();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()`
|
||||
41 | let _ = String::from(format!("A: {:04}", 123));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)`
|
||||
|
||||
error: identical conversion
|
||||
--> $DIR/identity_conversion.rs:42:13
|
||||
|
|
||||
42 | let _ = vec![1, 2, 3].into_iter().into_iter();
|
||||
42 | let _ = "".lines().into_iter();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()`
|
||||
|
||||
error: identical conversion
|
||||
--> $DIR/identity_conversion.rs:43:13
|
||||
|
|
||||
43 | let _ = vec![1, 2, 3].into_iter().into_iter();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user