]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/transmute.rs
Auto merge of #3946 - rchaser53:issue-3920, r=flip1995
[rust.git] / clippy_lints / src / transmute.rs
index 13226793e7e51d1a99c3d45b4db5c4e981d8b700..e4eb1bb0b7406bd739f8b6c9b0fdac5a7b6531a5 100644 (file)
@@ -1,5 +1,4 @@
-use crate::utils::{last_path_segment, match_def_path, paths, snippet, span_lint, span_lint_and_then};
-use crate::utils::{opt_def_id, sugg};
+use crate::utils::{last_path_segment, match_def_path, paths, snippet, span_lint, span_lint_and_then, sugg};
 use if_chain::if_chain;
 use rustc::hir::*;
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -231,7 +230,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
         if let ExprKind::Call(ref path_expr, ref args) = e.node {
             if let ExprKind::Path(ref qpath) = path_expr.node {
-                if let Some(def_id) = opt_def_id(cx.tables.qpath_def(qpath, path_expr.hir_id)) {
+                if let Some(def_id) = cx.tables.qpath_def(qpath, path_expr.hir_id).opt_def_id() {
                     if match_def_path(cx.tcx, def_id, &paths::TRANSMUTE) {
                         let from_ty = cx.tables.expr_ty(&args[0]);
                         let to_ty = cx.tables.expr_ty(e);
@@ -348,7 +347,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
                                     |db| {
                                         let arg = sugg::Sugg::hir(cx, &args[0], "..");
                                         let arg = if let ty::Int(_) = from_ty.sty {
-                                            arg.as_ty(ty::Uint(ast::UintTy::U32))
+                                            arg.as_ty(ast::UintTy::U32)
                                         } else {
                                             arg
                                         };
@@ -486,7 +485,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
     }
 }
 
-/// Get the snippet of `Bar` in `…::transmute<Foo, &Bar>`. If that snippet is
+/// Gets the snippet of `Bar` in `…::transmute<Foo, &Bar>`. If that snippet is
 /// not available , use
 /// the type's `ToString` implementation. In weird cases it could lead to types
 /// with invalid `'_`