- ExprKind::Call(ref path, ref args) => if let ExprKind::Path(ref qpath) = path.node {
- if let Some(def_id) = opt_def_id(resolve_node(cx, qpath, path.hir_id)) {
- if match_def_path(cx.tcx, def_id, &paths::FROM_FROM[..]) {
- 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.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_with_applicability(
- e.span,
- &sugg_msg,
- sugg,
- Applicability::MachineApplicable, // snippet
- );
- });
+ ExprKind::Call(ref path, ref args) => {
+ if let ExprKind::Path(ref qpath) = path.kind {
+ if let Some(def_id) = cx.tables.qpath_res(qpath, path.hir_id).opt_def_id() {
+ if match_def_path(cx, def_id, &paths::FROM_FROM) {
+ 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.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,
+ Applicability::MachineApplicable, // snippet
+ );
+ });
+ }