]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/utils/ptr.rs
rustup https://github.com/rust-lang/rust/pull/68944
[rust.git] / clippy_lints / src / utils / ptr.rs
index be7bd0d21f69cb4b8ab12ad90b4a4a6497e42016..238c2277a932bb02ed3f6a263db6669d24349a00 100644 (file)
@@ -1,10 +1,11 @@
 use crate::utils::{get_pat_name, match_var, snippet};
-use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
-use rustc::hir::*;
-use rustc::lint::LateContext;
+use rustc::hir::map::Map;
+use rustc_ast::ast::Name;
+use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
+use rustc_hir::{Body, BodyId, Expr, ExprKind, Param};
+use rustc_lint::LateContext;
+use rustc_span::source_map::Span;
 use std::borrow::Cow;
-use syntax::ast::Name;
-use syntax::source_map::Span;
 
 pub fn get_spans(
     cx: &LateContext<'_, '_>,
@@ -26,7 +27,7 @@ fn extract_clone_suggestions<'a, 'tcx>(
     cx: &LateContext<'a, 'tcx>,
     name: Name,
     replace: &[(&'static str, &'static str)],
-    body: &'tcx Body,
+    body: &'tcx Body<'_>,
 ) -> Option<Vec<(Span, Cow<'static, str>)>> {
     let mut visitor = PtrCloneVisitor {
         cx,
@@ -52,11 +53,13 @@ struct PtrCloneVisitor<'a, 'tcx> {
 }
 
 impl<'a, 'tcx> Visitor<'tcx> for PtrCloneVisitor<'a, 'tcx> {
-    fn visit_expr(&mut self, expr: &'tcx Expr) {
+    type Map = Map<'tcx>;
+
+    fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
         if self.abort {
             return;
         }
-        if let ExprKind::MethodCall(ref seg, _, ref args) = expr.node {
+        if let ExprKind::MethodCall(ref seg, _, ref args) = expr.kind {
             if args.len() == 1 && match_var(&args[0], self.name) {
                 if seg.ident.name.as_str() == "capacity" {
                     self.abort = true;
@@ -75,11 +78,11 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
         walk_expr(self, expr);
     }
 
-    fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+    fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
         NestedVisitorMap::None
     }
 }
 
-fn get_binding_name(arg: &Param) -> Option<Name> {
+fn get_binding_name(arg: &Param<'_>) -> Option<Name> {
     get_pat_name(&arg.pat)
 }