-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};
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);
|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
};
}
}
-/// 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 `'_`