]> git.lizzy.rs Git - rust.git/commitdiff
Rustup
authorMateusz Mikuła <mati865@gmail.com>
Thu, 28 Jun 2018 13:46:58 +0000 (15:46 +0200)
committerMateusz Mikuła <mati865@gmail.com>
Fri, 29 Jun 2018 07:49:05 +0000 (09:49 +0200)
48 files changed:
clippy_lints/src/attrs.rs
clippy_lints/src/blacklisted_name.rs
clippy_lints/src/booleans.rs
clippy_lints/src/bytecount.rs
clippy_lints/src/copies.rs
clippy_lints/src/duration_subsec.rs
clippy_lints/src/entry.rs
clippy_lints/src/enum_variants.rs
clippy_lints/src/eta_reduction.rs
clippy_lints/src/explicit_write.rs
clippy_lints/src/fallible_impl_from.rs
clippy_lints/src/format.rs
clippy_lints/src/identity_conversion.rs
clippy_lints/src/infinite_iter.rs
clippy_lints/src/inline_fn_without_body.rs
clippy_lints/src/len_zero.rs
clippy_lints/src/let_if_seq.rs
clippy_lints/src/lifetimes.rs
clippy_lints/src/loops.rs
clippy_lints/src/map_clone.rs
clippy_lints/src/matches.rs
clippy_lints/src/methods.rs
clippy_lints/src/misc.rs
clippy_lints/src/misc_early.rs
clippy_lints/src/mut_reference.rs
clippy_lints/src/needless_pass_by_value.rs
clippy_lints/src/new_without_default.rs
clippy_lints/src/open_options.rs
clippy_lints/src/partialeq_ne_impl.rs
clippy_lints/src/question_mark.rs
clippy_lints/src/ranges.rs
clippy_lints/src/returns.rs
clippy_lints/src/serde_api.rs
clippy_lints/src/shadow.rs
clippy_lints/src/strings.rs
clippy_lints/src/swap.rs
clippy_lints/src/types.rs
clippy_lints/src/unused_io_amount.rs
clippy_lints/src/unused_label.rs
clippy_lints/src/unwrap.rs
clippy_lints/src/use_self.rs
clippy_lints/src/utils/author.rs
clippy_lints/src/utils/hir_utils.rs
clippy_lints/src/utils/inspector.rs
clippy_lints/src/utils/internal_lints.rs
clippy_lints/src/utils/mod.rs
clippy_lints/src/utils/ptr.rs
clippy_lints/src/write.rs

index ebf1af52d22571276b2f05efd9f040304a520baa..b9d8976b28b4f0ce72face771ca2f1b5b3021df2 100644 (file)
@@ -195,13 +195,13 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
 
     fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
         if is_relevant_impl(cx.tcx, item) {
-            check_attrs(cx, item.span, item.name, &item.attrs)
+            check_attrs(cx, item.span, item.ident.name, &item.attrs)
         }
     }
 
     fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
         if is_relevant_trait(cx.tcx, item) {
-            check_attrs(cx, item.span, item.name, &item.attrs)
+            check_attrs(cx, item.span, item.ident.name, &item.attrs)
         }
     }
 }
index f1e8be4dba9df8d2d9d1d0733fcd29abfafdab9c..29660399233038f7f33fb3bfcd9639329b2c04d4 100644 (file)
@@ -41,13 +41,13 @@ fn get_lints(&self) -> LintArray {
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
     fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
-        if let PatKind::Binding(_, _, ref ident, _) = pat.node {
-            if self.blacklist.iter().any(|s| ident.node == *s) {
+        if let PatKind::Binding(_, _, ident, _) = pat.node {
+            if self.blacklist.iter().any(|s| ident.name == *s) {
                 span_lint(
                     cx,
                     BLACKLISTED_NAME,
                     ident.span,
-                    &format!("use of a blacklisted/placeholder name `{}`", ident.node),
+                    &format!("use of a blacklisted/placeholder name `{}`", ident.name),
                 );
             }
         }
index 0a453618e1939ff34b8ae4c09d97134535097004..b541bfc6b2fdc2de693e9bd377c0affadc71ab25 100644 (file)
@@ -203,7 +203,7 @@ fn simplify_not(&self, expr: &Expr) -> Option<String> {
                 METHODS_WITH_NEGATION
                     .iter().cloned()
                     .flat_map(|(a, b)| vec![(a, b), (b, a)])
-                    .find(|&(a, _)| a == path.name.as_str())
+                    .find(|&(a, _)| a == path.ident.as_str())
                     .and_then(|(_, neg_method)| Some(format!("{}.{}()", self.snip(&args[0])?, neg_method)))
             },
             _ => None,
index 165c46164bbc255f6bcb9cd1e2cb21fec71ae159..6f2ea320f932ec5ef9ea0fd629111d8507d06002 100644 (file)
@@ -39,10 +39,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
     fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
         if_chain! {
             if let ExprMethodCall(ref count, _, ref count_args) = expr.node;
-            if count.name == "count";
+            if count.ident.name == "count";
             if count_args.len() == 1;
             if let ExprMethodCall(ref filter, _, ref filter_args) = count_args[0].node;
-            if filter.name == "filter";
+            if filter.ident.name == "filter";
             if filter_args.len() == 2;
             if let ExprClosure(_, _, body_id, _, _) = filter_args[1].node;
             then {
@@ -68,7 +68,7 @@ fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
                         }
                         let haystack = if let ExprMethodCall(ref path, _, ref args) =
                                 filter_args[0].node {
-                            let p = path.name;
+                            let p = path.ident.name;
                             if (p == "iter" || p == "iter_mut") && args.len() == 1 {
                                 &args[0]
                             } else {
@@ -104,7 +104,7 @@ fn get_path_name(expr: &Expr) -> Option<Name> {
         } else {
             None
         },
-        ExprPath(ref qpath) => single_segment_path(qpath).map(|ps| ps.name),
+        ExprPath(ref qpath) => single_segment_path(qpath).map(|ps| ps.ident.name),
         _ => None,
     }
 }
index 2e2489cbb4a1827a288967faeed1a7322f4635dd..430ff59cd4d32d8c483fc830b8b55749644044f2 100644 (file)
@@ -269,8 +269,8 @@ fn bindings_impl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat, map: &mut Hash
             PatKind::TupleStruct(_, ref pats, _) => for pat in pats {
                 bindings_impl(cx, pat, map);
             },
-            PatKind::Binding(_, _, ref ident, ref as_pat) => {
-                if let Entry::Vacant(v) = map.entry(ident.node.as_str()) {
+            PatKind::Binding(_, _, ident, ref as_pat) => {
+                if let Entry::Vacant(v) = map.entry(ident.as_str()) {
                     v.insert(cx.tables.pat_ty(pat));
                 }
                 if let Some(ref as_pat) = *as_pat {
index 5f34803c81379c0ab073b24bbda7e2748fe2cde3..16b94d24b16a471c8a081b8d4d86818f440bb03c 100644 (file)
@@ -43,7 +43,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
             if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::DURATION);
             if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables, right);
             then {
-                let suggested_fn = match (method_path.name.as_str().as_ref(), divisor) {
+                let suggested_fn = match (method_path.ident.as_str().as_ref(), divisor) {
                     ("subsec_micros", 1_000) => "subsec_millis",
                     ("subsec_nanos", 1_000) => "subsec_micros",
                     ("subsec_nanos", 1_000_000) => "subsec_millis",
index 24e1b2d83876ad2863e9b46136dadcadb82c3fa7..13c75f39bb8902174c2553c1d12508f2adea2ddb 100644 (file)
@@ -90,7 +90,7 @@ fn check_cond<'a, 'tcx, 'b>(
     if_chain! {
         if let ExprMethodCall(ref path, _, ref params) = check.node;
         if params.len() >= 2;
-        if path.name == "contains_key";
+        if path.ident.name == "contains_key";
         if let ExprAddrOf(_, ref key) = params[1].node;
         then {
             let map = &params[0];
@@ -125,7 +125,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
         if_chain! {
             if let ExprMethodCall(ref path, _, ref params) = expr.node;
             if params.len() == 3;
-            if path.name == "insert";
+            if path.ident.name == "insert";
             if get_item_name(self.cx, self.map) == get_item_name(self.cx, &params[0]);
             if SpanlessEq::new(self.cx).eq_expr(self.key, &params[1]);
             then {
index f11edbeefa31fc56eb3222f79d69625e211a2da9..a200383b41d166debeb2e8170668e3c4e12b0562 100644 (file)
@@ -121,7 +121,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 fn var2str(var: &Variant) -> LocalInternedString {
-    var.node.ident.name.as_str()
+    var.node.ident.as_str()
 }
 
 /// Returns the number of chars that match from the start
@@ -245,7 +245,7 @@ fn check_item_post(&mut self, _cx: &EarlyContext, _item: &Item) {
     }
 
     fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
-        let item_name = item.ident.name.as_str();
+        let item_name = item.ident.as_str();
         let item_name_chars = item_name.chars().count();
         let item_camel = to_camel_case(&item_name);
         if !in_macro(item.span) {
index 30ea9f2446ad2268a2e7e4d5cf3e85b9a312fb5f..e924ba6bdbb75ff8e2c3cd58f8a097df64731eac 100644 (file)
@@ -78,7 +78,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
                             // If it's a proper path, it can't be a local variable
                             return;
                         }
-                        if p.segments[0].name != ident.node {
+                        if p.segments[0].ident.name != ident.name {
                             // The two idents should be the same
                             return;
                         }
index feff746ba0cda993b81b1de2dda65a5309eed76e..7c741100bde317dad57ebc0cc15bdf309dfb8554 100644 (file)
@@ -36,12 +36,12 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
         if_chain! {
             // match call to unwrap
             if let ExprMethodCall(ref unwrap_fun, _, ref unwrap_args) = expr.node;
-            if unwrap_fun.name == "unwrap";
+            if unwrap_fun.ident.name == "unwrap";
             // match call to write_fmt
             if unwrap_args.len() > 0;
             if let ExprMethodCall(ref write_fun, _, ref write_args) =
                 unwrap_args[0].node;
-            if write_fun.name == "write_fmt";
+            if write_fun.ident.name == "write_fmt";
             // match calls to std::io::stdout() / std::io::stderr ()
             if write_args.len() > 0;
             if let ExprCall(ref dest_fun, _) = write_args[0].node;
index 7e05712aa1aa18e4ad26ecd5b8abf66f74206b4d..64cdc05b44de33fc9e978fb597885878f49de23d 100644 (file)
@@ -93,7 +93,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
 
     for impl_item in impl_items {
         if_chain! {
-            if impl_item.name == "from";
+            if impl_item.ident.name == "from";
             if let ImplItemKind::Method(_, body_id) =
                 cx.tcx.hir.impl_item(impl_item.id).node;
             then {
index 072b68d6beb9f19c292bcb142afa043897ca5b88..890fe51819aaf923f11fa89c9e25a78b4edc4477 100644 (file)
@@ -151,7 +151,7 @@ fn check_unformatted(expr: &Expr) -> bool {
         if let ExprStruct(_, ref fields, _) = format_field.expr.node;
         if let Some(align_field) = fields.iter().find(|f| f.ident.name == "width");
         if let ExprPath(ref qpath) = align_field.expr.node;
-        if last_path_segment(qpath).name == "Implied";
+        if last_path_segment(qpath).ident.name == "Implied";
         then {
             return true;
         }
index d8b8e8f073b2cbdfacc334f614cf1233de8e8a88..2effb8bd8dbc7457a17e118dcee4454e67529981 100644 (file)
@@ -56,7 +56,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
             },
 
             ExprMethodCall(ref name, .., ref args) => {
-                if match_trait_method(cx, e, &paths::INTO[..]) && &*name.name.as_str() == "into" {
+                if match_trait_method(cx, e, &paths::INTO[..]) && &*name.ident.as_str() == "into" {
                     let a = cx.tables.expr_ty(e);
                     let b = cx.tables.expr_ty(&args[0]);
                     if same_tys(cx, a, b) {
index cb31c1cd044a0862ae12af6dfc0cc45a812cf8e0..8f6d499329f3ea7056e5b1f0964650a79eb57ec4 100644 (file)
@@ -143,7 +143,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
     match expr.node {
         ExprMethodCall(ref method, _, ref args) => {
             for &(name, len, heuristic, cap) in HEURISTICS.iter() {
-                if method.name == name && args.len() == len {
+                if method.ident.name == name && args.len() == len {
                     return (match heuristic {
                         Always => Infinite,
                         First => is_infinite(cx, &args[0]),
@@ -152,7 +152,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
                     }).and(cap);
                 }
             }
-            if method.name == "flat_map" && args.len() == 2 {
+            if method.ident.name == "flat_map" && args.len() == 2 {
                 if let ExprClosure(_, _, body_id, _, _) = args[1].node {
                     let body = cx.tcx.hir.body(body_id);
                     return is_infinite(cx, &body.value);
@@ -207,16 +207,16 @@ fn complete_infinite_iter(cx: &LateContext, expr: &Expr) -> Finiteness {
     match expr.node {
         ExprMethodCall(ref method, _, ref args) => {
             for &(name, len) in COMPLETING_METHODS.iter() {
-                if method.name == name && args.len() == len {
+                if method.ident.name == name && args.len() == len {
                     return is_infinite(cx, &args[0]);
                 }
             }
             for &(name, len) in POSSIBLY_COMPLETING_METHODS.iter() {
-                if method.name == name && args.len() == len {
+                if method.ident.name == name && args.len() == len {
                     return MaybeInfinite.and(is_infinite(cx, &args[0]));
                 }
             }
-            if method.name == "last" && args.len() == 1 {
+            if method.ident.name == "last" && args.len() == 1 {
                 let not_double_ended = get_trait_def_id(cx, &paths::DOUBLE_ENDED_ITERATOR)
                     .map_or(false, |id| !implements_trait(cx, cx.tables.expr_ty(&args[0]), id, &[]));
                 if not_double_ended {
index 1325ad66857b5360ee687dbb21453757bfb6855a..8dab9fbd12f67bc9b0b5105c61e0930f62805aa8 100644 (file)
@@ -38,7 +38,7 @@ fn get_lints(&self) -> LintArray {
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
     fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
         if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.node {
-            check_attrs(cx, item.name, &item.attrs);
+            check_attrs(cx, item.ident.name, &item.attrs);
         }
     }
 }
index fe9eb2e2d38c3b5b16c2c1960c81aec62d24a8dd..33930ab58db471619f180e3e730c8bdccd6a8ffa 100644 (file)
@@ -107,7 +107,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
 
 fn check_trait_items(cx: &LateContext, visited_trait: &Item, trait_items: &[TraitItemRef]) {
     fn is_named_self(cx: &LateContext, item: &TraitItemRef, name: &str) -> bool {
-        item.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
+        item.ident.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
             has_self && {
                 let did = cx.tcx.hir.local_def_id(item.id.node_id);
                 cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
@@ -135,7 +135,7 @@ fn fill_trait_set(traitt: DefId, set: &mut HashSet<DefId>, cx: &LateContext) {
             .iter()
             .flat_map(|&i| cx.tcx.associated_items(i))
             .any(|i| {
-                i.kind == ty::AssociatedKind::Method && i.method_has_self_argument && i.name == "is_empty"
+                i.kind == ty::AssociatedKind::Method && i.method_has_self_argument && i.ident.name == "is_empty"
                     && cx.tcx.fn_sig(i.def_id).inputs().skip_binder().len() == 1
             });
 
@@ -155,7 +155,7 @@ fn fill_trait_set(traitt: DefId, set: &mut HashSet<DefId>, cx: &LateContext) {
 
 fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
     fn is_named_self(cx: &LateContext, item: &ImplItemRef, name: &str) -> bool {
-        item.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
+        item.ident.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
             has_self && {
                 let did = cx.tcx.hir.local_def_id(item.id.node_id);
                 cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
@@ -202,7 +202,7 @@ fn check_cmp(cx: &LateContext, span: Span, method: &Expr, lit: &Expr, op: &str,
             }
         }
 
-        check_len(cx, span, method_path.name, args, lit, op, compare_to)
+        check_len(cx, span, method_path.ident.name, args, lit, op, compare_to)
     }
 }
 
@@ -235,7 +235,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
     /// Get an `AssociatedItem` and return true if it matches `is_empty(self)`.
     fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool {
         if let ty::AssociatedKind::Method = item.kind {
-            if item.name == "is_empty" {
+            if item.ident.name == "is_empty" {
                 let sig = cx.tcx.fn_sig(item.def_id);
                 let ty = sig.skip_binder();
                 ty.inputs().len() == 1
index b114a285f97a26baa21bac8cfa78bf83e5a21e6a..4e0d3de799e5d1b64197c1188b2145ef370fec99 100644 (file)
@@ -67,7 +67,7 @@ fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block) {
                 if let Some(expr) = it.peek();
                 if let hir::StmtDecl(ref decl, _) = stmt.node;
                 if let hir::DeclLocal(ref decl) = decl.node;
-                if let hir::PatKind::Binding(mode, canonical_id, ref name, None) = decl.pat.node;
+                if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node;
                 if let hir::StmtExpr(ref if_, _) = expr.node;
                 if let hir::ExprIf(ref cond, ref then, ref else_) = if_.node;
                 if !used_in_expr(cx, canonical_id, cond);
@@ -106,7 +106,7 @@ fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block) {
                     let sug = format!(
                         "let {mut}{name} = if {cond} {{{then} {value} }} else {{{else} {default} }};",
                         mut=mutability,
-                        name=name.node,
+                        name=ident.name,
                         cond=snippet(cx, cond.span, "_"),
                         then=if then.stmts.len() > 1 { " ..;" } else { "" },
                         else=if default_multi_stmts { " ..;" } else { "" },
index 1c063464fcc27a00cc7da016151ca94b583b9cd4..efa50a8f7435d7650a900f9818b0265a4199c345 100644 (file)
@@ -126,7 +126,7 @@ fn check_fn_inner<'a, 'tcx>(
                         GenericArg::Type(_) => None,
                     });
                     for bound in lifetimes {
-                        if bound.name.name() != "'static" && !bound.is_elided() {
+                        if bound.name.ident().name != "'static" && !bound.is_elided() {
                             return;
                         }
                         bounds_lts.push(bound);
@@ -240,7 +240,7 @@ fn allowed_lts_from(named_generics: &[GenericParam]) -> HashSet<RefLt> {
     for par in named_generics.iter() {
         if let GenericParamKind::Lifetime { .. } = par.kind {
             if par.bounds.is_empty() {
-                allowed_lts.insert(RefLt::Named(par.name.name()));
+                allowed_lts.insert(RefLt::Named(par.name.ident().name));
             }
         }
     }
@@ -251,8 +251,8 @@ fn allowed_lts_from(named_generics: &[GenericParam]) -> HashSet<RefLt> {
 
 fn lts_from_bounds<'a, T: Iterator<Item = &'a Lifetime>>(mut vec: Vec<RefLt>, bounds_lts: T) -> Vec<RefLt> {
     for lt in bounds_lts {
-        if lt.name.name() != "'static" {
-            vec.push(RefLt::Named(lt.name.name()));
+        if lt.name.ident().name != "'static" {
+            vec.push(RefLt::Named(lt.name.ident().name));
         }
     }
 
@@ -282,12 +282,12 @@ fn new(cx: &'v LateContext<'v, 't>) -> Self {
 
     fn record(&mut self, lifetime: &Option<Lifetime>) {
         if let Some(ref lt) = *lifetime {
-            if lt.name.name() == "'static" {
+            if lt.name.ident().name == "'static" {
                 self.lts.push(RefLt::Static);
             } else if lt.is_elided() {
                 self.lts.push(RefLt::Unnamed);
             } else {
-                self.lts.push(RefLt::Named(lt.name.name()));
+                self.lts.push(RefLt::Named(lt.name.ident().name));
             }
         } else {
             self.lts.push(RefLt::Unnamed);
@@ -421,7 +421,7 @@ struct LifetimeChecker {
 impl<'tcx> Visitor<'tcx> for LifetimeChecker {
     // for lifetimes as parameters of generics
     fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
-        self.map.remove(&lifetime.name.name());
+        self.map.remove(&lifetime.name.ident().name);
     }
 
     fn visit_generic_param(&mut self, param: &'tcx GenericParam) {
@@ -442,7 +442,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
 fn report_extra_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, generics: &'tcx Generics) {
     let hs = generics.params.iter()
         .filter_map(|par| match par.kind {
-            GenericParamKind::Lifetime { .. } => Some((par.name.name(), par.span)),
+            GenericParamKind::Lifetime { .. } => Some((par.name.ident().name, par.span)),
             _ => None,
         })
         .collect();
@@ -463,7 +463,7 @@ struct BodyLifetimeChecker {
 impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker {
     // for lifetimes as parameters of generics
     fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
-        if lifetime.name.name() != keywords::Invalid.name() && lifetime.name.name() != "'static" {
+        if lifetime.name.ident().name != keywords::Invalid.name() && lifetime.name.ident().name != "'static" {
             self.lifetimes_used_in_body = true;
         }
     }
index 8808de9025d2df9ec437d83be7cfa188f17498b7..8b7032893d88a332f278e5ff05970784df4c1c8a 100644 (file)
@@ -485,8 +485,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
             {
                 let iter_expr = &method_args[0];
                 let lhs_constructor = last_path_segment(qpath);
-                if method_path.name == "next" && match_trait_method(cx, match_expr, &paths::ITERATOR)
-                    && lhs_constructor.name == "Some" && !is_refutable(cx, &pat_args[0])
+                if method_path.ident.name == "next" && match_trait_method(cx, match_expr, &paths::ITERATOR)
+                    && lhs_constructor.ident.name == "Some" && !is_refutable(cx, &pat_args[0])
                     && !is_iterator_used_after_while_let(cx, iter_expr)
                     && !is_nested(cx, expr, &method_args[0])
                 {
@@ -513,7 +513,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
     fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
         if let StmtSemi(ref expr, _) = stmt.node {
             if let ExprMethodCall(ref method, _, ref args) = expr.node {
-                if args.len() == 1 && method.name == "collect" && match_trait_method(cx, expr, &paths::ITERATOR) {
+                if args.len() == 1 && method.ident.name == "collect" && match_trait_method(cx, expr, &paths::ITERATOR) {
                     span_lint(
                         cx,
                         UNUSED_COLLECT,
@@ -811,7 +811,7 @@ fn fetch_cloned_fixed_offset_var<'a, 'tcx>(
 ) -> Option<FixedOffsetVar> {
     if_chain! {
         if let ExprMethodCall(ref method, _, ref args) = expr.node;
-        if method.name == "clone";
+        if method.ident.name == "clone";
         if args.len() == 1;
         if let Some(arg) = args.get(0);
         then {
@@ -907,7 +907,7 @@ fn detect_manual_memcpy<'a, 'tcx>(
             let print_limit = |end: &Option<&Expr>, offset: Offset, var_name: &str| if let Some(end) = *end {
                 if_chain! {
                     if let ExprMethodCall(ref method, _, ref len_args) = end.node;
-                    if method.name == "len";
+                    if method.ident.name == "len";
                     if len_args.len() == 1;
                     if let Some(arg) = len_args.get(0);
                     if snippet(cx, arg.span, "??") == var_name;
@@ -985,7 +985,7 @@ fn check_for_loop_range<'a, 'tcx>(
     }) = higher::range(cx, arg)
     {
         // the var must be a single name
-        if let PatKind::Binding(_, canonical_id, ref ident, _) = pat.node {
+        if let PatKind::Binding(_, canonical_id, ident, _) = pat.node {
             let mut visitor = VarVisitor {
                 cx,
                 var: canonical_id,
@@ -1058,13 +1058,13 @@ fn check_for_loop_range<'a, 'tcx>(
                         cx,
                         NEEDLESS_RANGE_LOOP,
                         expr.span,
-                        &format!("the loop variable `{}` is used to index `{}`", ident.node, indexed),
+                        &format!("the loop variable `{}` is used to index `{}`", ident.name, indexed),
                         |db| {
                             multispan_sugg(
                                 db,
                                 "consider using an iterator".to_string(),
                                 vec![
-                                    (pat.span, format!("({}, <item>)", ident.node)),
+                                    (pat.span, format!("({}, <item>)", ident.name)),
                                     (arg.span, format!("{}.{}().enumerate(){}{}", indexed, method, take, skip)),
                                 ],
                             );
@@ -1081,7 +1081,7 @@ fn check_for_loop_range<'a, 'tcx>(
                         cx,
                         NEEDLESS_RANGE_LOOP,
                         expr.span,
-                        &format!("the loop variable `{}` is only used to index `{}`.", ident.node, indexed),
+                        &format!("the loop variable `{}` is only used to index `{}`.", ident.name, indexed),
                         |db| {
                             multispan_sugg(
                                 db,
@@ -1100,10 +1100,10 @@ fn is_len_call(expr: &Expr, var: Name) -> bool {
     if_chain! {
         if let ExprMethodCall(ref method, _, ref len_args) = expr.node;
         if len_args.len() == 1;
-        if method.name == "len";
+        if method.ident.name == "len";
         if let ExprPath(QPath::Resolved(_, ref path)) = len_args[0].node;
         if path.segments.len() == 1;
-        if path.segments[0].name == var;
+        if path.segments[0].ident.name == var;
         then {
             return true;
         }
@@ -1206,7 +1206,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
     if let ExprMethodCall(ref method, _, ref args) = arg.node {
         // just the receiver, no arguments
         if args.len() == 1 {
-            let method_name = &*method.name.as_str();
+            let method_name = &*method.ident.as_str();
             // check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
             if method_name == "iter" || method_name == "iter_mut" {
                 if is_ref_iterable_type(cx, &args[0]) {
@@ -1520,9 +1520,9 @@ fn check_for_mutation(cx: &LateContext, body: &Expr, bound_ids: &[Option<NodeId>
 fn pat_is_wild<'tcx>(pat: &'tcx PatKind, body: &'tcx Expr) -> bool {
     match *pat {
         PatKind::Wild => true,
-        PatKind::Binding(_, _, ident, None) if ident.node.as_str().starts_with('_') => {
+        PatKind::Binding(_, _, ident, None) if ident.as_str().starts_with('_') => {
             let mut visitor = UsedVisitor {
-                var: ident.node,
+                var: ident.name,
                 used: false,
             };
             walk_expr(&mut visitor, body);
@@ -1615,7 +1615,7 @@ fn check(&mut self, idx: &'tcx Expr, seqexpr: &'tcx Expr, expr: &'tcx Expr) -> b
 
                 if indexed_indirectly || index_used_directly {
                     if self.prefer_mutable {
-                        self.indexed_mut.insert(seqvar.segments[0].name);
+                        self.indexed_mut.insert(seqvar.segments[0].ident.name);
                     }
                     let def = self.cx.tables.qpath_def(seqpath, seqexpr.hir_id);
                     match def {
@@ -1626,19 +1626,19 @@ fn check(&mut self, idx: &'tcx Expr, seqexpr: &'tcx Expr, expr: &'tcx Expr) -> b
                             let parent_def_id = self.cx.tcx.hir.local_def_id(parent_id);
                             let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
                             if indexed_indirectly {
-                                self.indexed_indirectly.insert(seqvar.segments[0].name, Some(extent));
+                                self.indexed_indirectly.insert(seqvar.segments[0].ident.name, Some(extent));
                             }
                             if index_used_directly {
-                                self.indexed_directly.insert(seqvar.segments[0].name, Some(extent));
+                                self.indexed_directly.insert(seqvar.segments[0].ident.name, Some(extent));
                             }
                             return false;  // no need to walk further *on the variable*
                         }
                         Def::Static(..) | Def::Const(..) => {
                             if indexed_indirectly {
-                                self.indexed_indirectly.insert(seqvar.segments[0].name, None);
+                                self.indexed_indirectly.insert(seqvar.segments[0].ident.name, None);
                             }
                             if index_used_directly {
-                                self.indexed_directly.insert(seqvar.segments[0].name, None);
+                                self.indexed_directly.insert(seqvar.segments[0].ident.name, None);
                             }
                             return false;  // no need to walk further *on the variable*
                         }
@@ -1656,8 +1656,8 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
         if_chain! {
             // a range index op
             if let ExprMethodCall(ref meth, _, ref args) = expr.node;
-            if (meth.name == "index" && match_trait_method(self.cx, expr, &paths::INDEX))
-                || (meth.name == "index_mut" && match_trait_method(self.cx, expr, &paths::INDEX_MUT));
+            if (meth.ident.name == "index" && match_trait_method(self.cx, expr, &paths::INDEX))
+                || (meth.ident.name == "index_mut" && match_trait_method(self.cx, expr, &paths::INDEX_MUT));
             if !self.check(&args[1], &args[0], expr);
             then { return }
         }
@@ -1681,7 +1681,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
                     self.nonindex = true;
                 } else {
                     // not the correct variable, but still a variable
-                    self.referenced.insert(path.segments[0].name);
+                    self.referenced.insert(path.segments[0].ident.name);
                 }
             }
         }
@@ -1933,8 +1933,8 @@ fn visit_decl(&mut self, decl: &'tcx Decl) {
         // Look for declarations of the variable
         if let DeclLocal(ref local) = decl.node {
             if local.pat.id == self.var_id {
-                if let PatKind::Binding(_, _, ref ident, _) = local.pat.node {
-                    self.name = Some(ident.node);
+                if let PatKind::Binding(_, _, ident, _) = local.pat.node {
+                    self.name = Some(ident.name);
 
                     self.state = if let Some(ref init) = local.init {
                         if is_integer_literal(init, 0) {
@@ -2123,7 +2123,7 @@ fn visit_pat(&mut self, pat: &'tcx Pat) {
             return;
         }
         if let PatKind::Binding(_, _, span_name, _) = pat.node {
-            if self.iterator == span_name.node {
+            if self.iterator == span_name.name {
                 self.nesting = RuledOut;
                 return;
             }
@@ -2140,7 +2140,7 @@ fn path_name(e: &Expr) -> Option<Name> {
     if let ExprPath(QPath::Resolved(_, ref path)) = e.node {
         let segments = &path.segments;
         if segments.len() == 1 {
-            return Some(segments[0].name);
+            return Some(segments[0].ident.name);
         }
     };
     None
index 97c2522d2ced803c2b91d28e76752fd0facdba52..5ea873e31e1313dbbfb430fd5fa2b8fd9794662e 100644 (file)
@@ -2,7 +2,7 @@
 use rustc::hir::*;
 use rustc::ty;
 use syntax::ast;
-use crate::utils::{get_arg_name, is_adjusted, iter_input_pats, match_qpath, match_trait_method, match_type,
+use crate::utils::{get_arg_ident, is_adjusted, iter_input_pats, match_qpath, match_trait_method, match_type,
             paths, remove_blocks, snippet, span_help_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth};
 
 /// **What it does:** Checks for mapping `clone()` over an iterator.
@@ -31,7 +31,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
         // call to .map()
         if let ExprMethodCall(ref method, _, ref args) = expr.node {
-            if method.name == "map" && args.len() == 2 {
+            if method.ident.name == "map" && args.len() == 2 {
                 match args[1].node {
                     ExprClosure(_, ref decl, closure_eid, _, _) => {
                         let body = cx.tcx.hir.body(closure_eid);
@@ -40,7 +40,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
                             // nothing special in the argument, besides reference bindings
                             // (e.g. .map(|&x| x) )
                             if let Some(first_arg) = iter_input_pats(decl, body).next();
-                            if let Some(arg_ident) = get_arg_name(&first_arg.pat);
+                            if let Some(arg_ident) = get_arg_ident(&first_arg.pat);
                             // the method is being called on a known type (option or iterator)
                             if let Some(type_name) = get_type_name(cx, expr, &args[0]);
                             then {
@@ -63,7 +63,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
                                 }
                                 // explicit clone() calls ( .map(|x| x.clone()) )
                                 else if let ExprMethodCall(ref clone_call, _, ref clone_args) = closure_expr.node {
-                                    if clone_call.name == "clone" &&
+                                    if clone_call.ident.name == "clone" &&
                                         clone_args.len() == 1 &&
                                         match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) &&
                                         expr_eq_name(&clone_args[0], arg_ident)
@@ -98,12 +98,12 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
     }
 }
 
-fn expr_eq_name(expr: &Expr, id: ast::Name) -> bool {
+fn expr_eq_name(expr: &Expr, id: ast::Ident) -> bool {
     match expr.node {
         ExprPath(QPath::Resolved(None, ref path)) => {
             let arg_segment = [
                 PathSegment {
-                    name: id,
+                    ident: id,
                     args: None,
                     infer_types: true,
                 },
@@ -124,7 +124,7 @@ fn get_type_name(cx: &LateContext, expr: &Expr, arg: &Expr) -> Option<&'static s
     }
 }
 
-fn only_derefs(cx: &LateContext, expr: &Expr, id: ast::Name) -> bool {
+fn only_derefs(cx: &LateContext, expr: &Expr, id: ast::Ident) -> bool {
     match expr.node {
         ExprUnary(UnDeref, ref subexpr) if !is_adjusted(cx, subexpr) => only_derefs(cx, subexpr, id),
         _ => expr_eq_name(expr, id),
index 8ab0482bacfdba2bb87bd2f46c6f78b28f0f8415..207343c92c678125cd3208dcfa3f5606e6c9a465 100644 (file)
@@ -270,7 +270,7 @@ fn check_single_match_opt_like(cx: &LateContext, ex: &Expr, arms: &[Arm], expr:
             }
             print::to_string(print::NO_ANN, |s| s.print_qpath(path, false))
         },
-        PatKind::Binding(BindingAnnotation::Unannotated, _, ident, None) => ident.node.to_string(),
+        PatKind::Binding(BindingAnnotation::Unannotated, _, ident, None) => ident.to_string(),
         PatKind::Path(ref path) => print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)),
         _ => return,
     };
@@ -552,14 +552,14 @@ fn is_ref_some_arm(arm: &Arm) -> Option<BindingAnnotation> {
     if_chain! {
         if let PatKind::TupleStruct(ref path, ref pats, _) = arm.pats[0].node;
         if pats.len() == 1 && match_qpath(path, &paths::OPTION_SOME);
-        if let PatKind::Binding(rb, _, ref ident, _) = pats[0].node;
+        if let PatKind::Binding(rb, _, ident, _) = pats[0].node;
         if rb == BindingAnnotation::Ref || rb == BindingAnnotation::RefMut;
         if let ExprCall(ref e, ref args) = remove_blocks(&arm.body).node;
         if let ExprPath(ref some_path) = e.node;
         if match_qpath(some_path, &paths::OPTION_SOME) && args.len() == 1;
         if let ExprPath(ref qpath) = args[0].node;
         if let &QPath::Resolved(_, ref path2) = qpath;
-        if path2.segments.len() == 1 && ident.node == path2.segments[0].name;
+        if path2.segments.len() == 1 && ident.name == path2.segments[0].ident.name;
         then {
             return Some(rb)
         }
index b5e1780fd0ca062cb917845907859cefdf139920..71f9dc8e03fb1595d1142b14a7fa7ab274e30a72 100644 (file)
@@ -771,18 +771,18 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
                     lint_unnecessary_fold(cx, expr, arglists[0]);
                 }
 
-                lint_or_fun_call(cx, expr, *method_span, &method_call.name.as_str(), args);
-                lint_expect_fun_call(cx, expr, *method_span, &method_call.name.as_str(), args);
+                lint_or_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args);
+                lint_expect_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args);
 
                 let self_ty = cx.tables.expr_ty_adjusted(&args[0]);
-                if args.len() == 1 && method_call.name == "clone" {
+                if args.len() == 1 && method_call.ident.name == "clone" {
                     lint_clone_on_copy(cx, expr, &args[0], self_ty);
                     lint_clone_on_ref_ptr(cx, expr, &args[0]);
                 }
 
                 match self_ty.sty {
                     ty::TyRef(_, ty, _) if ty.sty == ty::TyStr => for &(method, pos) in &PATTERN_METHODS {
-                        if method_call.name == method && args.len() > pos {
+                        if method_call.ident.name == method && args.len() > pos {
                             lint_single_char_pattern(cx, expr, &args[pos]);
                         }
                     },
@@ -806,7 +806,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::I
         if in_external_macro(cx, implitem.span) {
             return;
         }
-        let name = implitem.name;
+        let name = implitem.ident.name;
         let parent = cx.tcx.hir.get_parent(implitem.id);
         let item = cx.tcx.hir.expect_item(parent);
         if_chain! {
@@ -890,7 +890,7 @@ fn check_unwrap_or_default(
 
         if name == "unwrap_or" {
             if let hir::ExprPath(ref qpath) = fun.node {
-                let path = &*last_path_segment(qpath).name.as_str();
+                let path = &*last_path_segment(qpath).ident.as_str();
 
                 if ["default", "new"].contains(&path) {
                     let arg_ty = cx.tables.expr_ty(arg);
@@ -1438,7 +1438,7 @@ fn may_slice(cx: &LateContext, ty: Ty) -> bool {
     }
 
     if let hir::ExprMethodCall(ref path, _, ref args) = expr.node {
-        if path.name == "iter" && may_slice(cx, cx.tables.expr_ty(&args[0])) {
+        if path.ident.name == "iter" && may_slice(cx, cx.tables.expr_ty(&args[0])) {
             sugg::Sugg::hir_opt(cx, &args[0]).map(|sugg| sugg.addr())
         } else {
             None
@@ -1794,7 +1794,7 @@ fn lint_chars_cmp<'a, 'tcx>(
         if arg_char.len() == 1;
         if let hir::ExprPath(ref qpath) = fun.node;
         if let Some(segment) = single_segment_path(qpath);
-        if segment.name == "Some";
+        if segment.ident.name == "Some";
         then {
             let self_ty = walk_ptrs_ty(cx.tables.expr_ty_adjusted(&args[0][0]));
 
@@ -2093,7 +2093,7 @@ fn is_as_ref_or_mut_trait(ty: &hir::Ty, self_ty: &hir::Ty, generics: &hir::Gener
     single_segment_ty(ty).map_or(false, |seg| {
         generics.params.iter().any(|param| match param.kind {
             hir::GenericParamKind::Type { .. } => {
-                param.name.name() == seg.name && param.bounds.iter().any(|bound| {
+                param.name.ident().name == seg.ident.name && param.bounds.iter().any(|bound| {
                     if let hir::GenericBound::Trait(ref ptr, ..) = *bound {
                         let path = &ptr.trait_ref.path;
                         match_path(path, name) && path.segments.last().map_or(false, |s| {
@@ -2132,8 +2132,8 @@ fn is_ty(ty: &hir::Ty, self_ty: &hir::Ty) -> bool {
         ) => ty_path
             .segments
             .iter()
-            .map(|seg| seg.name)
-            .eq(self_ty_path.segments.iter().map(|seg| seg.name)),
+            .map(|seg| seg.ident.name)
+            .eq(self_ty_path.segments.iter().map(|seg| seg.ident.name)),
         _ => false,
     }
 }
index 414e507a55b4651892428cc8349b58038e6f24fa..697f15bdd1da5dec4189d1585ed24e11651d20a3 100644 (file)
@@ -379,7 +379,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
         }
         let binding = match expr.node {
             ExprPath(ref qpath) => {
-                let binding = last_path_segment(qpath).name.as_str();
+                let binding = last_path_segment(qpath).ident.as_str();
                 if binding.starts_with('_') &&
                     !binding.starts_with("__") &&
                     binding != "_result" && // FIXME: #944
@@ -417,13 +417,13 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
     }
 
     fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
-        if let PatKind::Binding(_, _, ref ident, Some(ref right)) = pat.node {
+        if let PatKind::Binding(_, _, ident, Some(ref right)) = pat.node {
             if right.node == PatKind::Wild {
                 span_lint(
                     cx,
                     REDUNDANT_PATTERN,
                     pat.span,
-                    &format!("the `{} @ _` pattern can be written as just `{}`", ident.node, ident.node),
+                    &format!("the `{} @ _` pattern can be written as just `{}`", ident.name, ident.name),
                 );
             }
         }
@@ -433,7 +433,7 @@ fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
 fn check_nan(cx: &LateContext, path: &Path, expr: &Expr) {
     if !in_constant(cx, expr.id) {
         if let Some(seg) = path.segments.last() {
-            if seg.name == "NAN" {
+            if seg.ident.name == "NAN" {
                 span_lint(
                     cx,
                     CMP_NAN,
index 96a3250d272cc3f0ac91608d7d389c91b1977374..87e4d343ab45b87f36618c380df77059c3c4c623 100644 (file)
@@ -190,7 +190,7 @@ impl EarlyLintPass for MiscEarly {
     fn check_generics(&mut self, cx: &EarlyContext, gen: &Generics) {
         for param in &gen.params {
             if let GenericParamKind::Type { .. } = param.kind {
-                let name = param.ident.name.as_str();
+                let name = param.ident.as_str();
                 if constants::BUILTIN_TYPES.contains(&&*name) {
                     span_lint(
                         cx,
@@ -268,7 +268,7 @@ fn check_fn(&mut self, cx: &EarlyContext, _: FnKind, decl: &FnDecl, _: Span, _:
 
         for arg in &decl.inputs {
             if let PatKind::Ident(_, ident, None) = arg.pat.node {
-                let arg_name = ident.name.to_string();
+                let arg_name = ident.to_string();
 
                 if arg_name.starts_with('_') {
                     if let Some(correspondence) = registered_names.get(&arg_name[1..]) {
index 4537f279b1e87dfd9a9802be8b92879c3ca0dca9..4e9c5c815cce9da1f8771f02d7f5f4361bcc2f52 100644 (file)
@@ -48,7 +48,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
                 let def_id = cx.tables.type_dependent_defs()[e.hir_id].def_id();
                 let substs = cx.tables.node_substs(e.hir_id);
                 let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
-                check_arguments(cx, arguments, method_type, &path.name.as_str())
+                check_arguments(cx, arguments, method_type, &path.ident.as_str())
             },
             _ => (),
         }
index 03a45bc18472f7fd12662b555cb9aa7102aec557..bdef092b5332c98aa712fe62b44a610ea32111e3 100644 (file)
@@ -152,8 +152,8 @@ fn check_fn(
 
             // Ignore `self`s.
             if idx == 0 {
-                if let PatKind::Binding(_, _, name, ..) = arg.pat.node {
-                    if name.node.as_str() == "self" {
+                if let PatKind::Binding(_, _, ident, ..) = arg.pat.node {
+                    if ident.as_str() == "self" {
                         continue;
                     }
                 }
@@ -217,7 +217,7 @@ fn check_fn(
                                 get_spans(cx, Some(body.id()), idx, &[("clone", ".to_owned()")]);
                             if let TyPath(QPath::Resolved(_, ref path)) = input.node;
                             if let Some(elem_ty) = path.segments.iter()
-                                .find(|seg| seg.name == "Vec")
+                                .find(|seg| seg.ident.name == "Vec")
                                 .and_then(|ps| ps.args.as_ref())
                                 .map(|params| params.args.iter().find_map(|arg| match arg {
                                     GenericArg::Type(ty) => Some(ty),
index adc91bacdef7ef2d1623453466012dc2ed9a962e..3f7cbaa6ca1683f6b47f5f98872abf01ad1c64e3 100644 (file)
@@ -97,7 +97,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
                         return;
                     }
                     if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node {
-                        let name = impl_item.name;
+                        let name = impl_item.ident.name;
                         let id = impl_item.id;
                         if sig.header.constness == hir::Constness::Const {
                             // can't be implemented by default
index 142447ee345d3207e1456c2f17451d01d111287a..fbece8226597fde66ef67148b499cf5f9aa75540 100644 (file)
@@ -35,7 +35,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSensical {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
         if let ExprMethodCall(ref path, _, ref arguments) = e.node {
             let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(&arguments[0]));
-            if path.name == "open" && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) {
+            if path.ident.name == "open" && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) {
                 let mut options = Vec::new();
                 get_open_options(cx, &arguments[0], &mut options);
                 check_open_options(cx, &options, e.span);
@@ -87,7 +87,7 @@ fn get_open_options(cx: &LateContext, argument: &Expr, options: &mut Vec<(OpenOp
                 _ => Argument::Unknown,
             };
 
-            match &*path.name.as_str() {
+            match &*path.ident.as_str() {
                 "create" => {
                     options.push((OpenOption::Create, argument_option));
                 },
index 1d80b78558bf33ba1aec51be01ad1aed397e2fff..1d9260e2aa79216db0db37feffef5869f1ddf947 100644 (file)
@@ -44,7 +44,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
             if trait_ref.path.def.def_id() == eq_trait;
             then {
                 for impl_item in impl_items {
-                    if impl_item.name == "ne" {
+                    if impl_item.ident.name == "ne" {
                         span_lint(cx,
                                   PARTIALEQ_NE_IMPL,
                                   impl_item.span,
index d2d9b22d212ebede592c48c6b0727851c1d865ff..d12f6ddd15a4cd600e9c4f48a1a228650499bc9f 100644 (file)
@@ -54,7 +54,7 @@ fn check_is_none_and_early_return_none(cx: &LateContext, expr: &Expr) {
         if_chain! {
             if let ExprIf(ref if_expr, ref body, _) = expr.node;
             if let ExprMethodCall(ref segment, _, ref args) = if_expr.node;
-            if segment.name == "is_none";
+            if segment.ident.name == "is_none";
             if Self::expression_returns_none(cx, body);
             if let Some(subject) = args.get(0);
             if Self::is_option(cx, subject);
index 4947479115e6e9af5d2dfddfa934d099fedecb38..6ec624d26e9271a10b4e239274565d971f3d6003 100644 (file)
@@ -89,7 +89,7 @@ fn get_lints(&self) -> LintArray {
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
         if let ExprMethodCall(ref path, _, ref args) = expr.node {
-            let name = path.name.as_str();
+            let name = path.ident.as_str();
 
             // Range with step_by(0).
             if name == "step_by" && args.len() == 2 && has_step_by(cx, &args[0]) {
@@ -108,13 +108,13 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
                 if_chain! {
                     // .iter() call
                     if let ExprMethodCall(ref iter_path, _, ref iter_args ) = *iter;
-                    if iter_path.name == "iter";
+                    if iter_path.ident.name == "iter";
                     // range expression in .zip() call: 0..x.len()
                     if let Some(higher::Range { start: Some(start), end: Some(end), .. }) = higher::range(cx, zip_arg);
                     if is_integer_literal(start, 0);
                     // .len() call
                     if let ExprMethodCall(ref len_path, _, ref len_args) = end.node;
-                    if len_path.name == "len" && len_args.len() == 1;
+                    if len_path.ident.name == "len" && len_args.len() == 1;
                     // .iter() and .len() called on same Path
                     if let ExprPath(QPath::Resolved(_, ref iter_path)) = iter_args[0].node;
                     if let ExprPath(QPath::Resolved(_, ref len_path)) = len_args[0].node;
index 73fbc172c1010208f0228c789f5bb02e4c174251..03a5d58a3eecd7f4a170a776cd6d51a3d0b8957c 100644 (file)
@@ -114,7 +114,7 @@ fn check_let_return(&mut self, cx: &EarlyContext, block: &ast::Block) {
             if let Some(ref initexpr) = local.init;
             if let ast::PatKind::Ident(_, ident, _) = local.pat.node;
             if let ast::ExprKind::Path(_, ref path) = retexpr.node;
-            if match_path_ast(path, &[&ident.name.as_str()]);
+            if match_path_ast(path, &[&ident.as_str()]);
             if !in_external_macro(cx, initexpr.span);
             then {
                     span_note_and_lint(cx,
index a56a05470f20d3e87f2ffbdc2b85e2f5cd3142d0..a4bdd89a0378cc9e93d2a4cdfd90e90835921c50 100644 (file)
@@ -36,7 +36,7 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
                     let mut seen_str = None;
                     let mut seen_string = None;
                     for item in items {
-                        match &*item.name.as_str() {
+                        match &*item.ident.as_str() {
                             "visit_str" => seen_str = Some(item.span),
                             "visit_string" => seen_string = Some(item.span),
                             _ => {},
index 12ba6970675efd5ab3af1fb8dd2510b94d3b1cc1..d37023e4f8c817c5177ce4e915013875e79e0752 100644 (file)
@@ -100,7 +100,7 @@ fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, body: &'tc
     let mut bindings = Vec::new();
     for arg in iter_input_pats(decl, body) {
         if let PatKind::Binding(_, _, ident, _) = arg.pat.node {
-            bindings.push((ident.node, ident.span))
+            bindings.push((ident.name, ident.span))
         }
     }
     check_expr(cx, &body.value, &mut bindings);
@@ -164,8 +164,8 @@ fn check_pat<'a, 'tcx>(
 ) {
     // TODO: match more stuff / destructuring
     match pat.node {
-        PatKind::Binding(_, _, ref ident, ref inner) => {
-            let name = ident.node;
+        PatKind::Binding(_, _, ident, ref inner) => {
+            let name = ident.name;
             if is_binding(cx, pat.hir_id) {
                 let mut new_binding = true;
                 for tup in bindings.iter_mut() {
@@ -378,5 +378,5 @@ fn is_self_shadow(name: Name, expr: &Expr) -> bool {
 }
 
 fn path_eq_name(name: Name, path: &Path) -> bool {
-    !path.is_global() && path.segments.len() == 1 && path.segments[0].name.as_str() == name.as_str()
+    !path.is_global() && path.segments.len() == 1 && path.segments[0].ident.as_str() == name.as_str()
 }
index 5b4a2d1f5049ad4b9ede2441afca20aa20a61a1a..62cd5de68f063713e6663b85df9904059650b3b4 100644 (file)
@@ -149,7 +149,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
         use crate::utils::{in_macro, snippet};
 
         if let ExprMethodCall(ref path, _, ref args) = e.node {
-            if path.name == "as_bytes" {
+            if path.ident.name == "as_bytes" {
                 if let ExprLit(ref lit) = args[0].node {
                     if let LitKind::Str(ref lit_content, _) = lit.node {
                         if lit_content.as_str().chars().all(|c| c.is_ascii()) && !in_macro(args[0].span) {
index 8de4638d13d012104539fbe67789eb867e2618ee..1037a1bc632ecc58b75edbccfc24f5f3c024f013 100644 (file)
@@ -64,7 +64,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) {
             if let StmtDecl(ref tmp, _) = w[0].node;
             if let DeclLocal(ref tmp) = tmp.node;
             if let Some(ref tmp_init) = tmp.init;
-            if let PatKind::Binding(_, _, ref tmp_name, None) = tmp.pat.node;
+            if let PatKind::Binding(_, _, ident, None) = tmp.pat.node;
 
             // foo() = bar();
             if let StmtSemi(ref first, _) = w[1].node;
@@ -76,7 +76,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) {
             if let ExprPath(QPath::Resolved(None, ref rhs2)) = rhs2.node;
             if rhs2.segments.len() == 1;
 
-            if tmp_name.node.as_str() == rhs2.segments[0].name.as_str();
+            if ident.as_str() == rhs2.segments[0].ident.as_str();
             if SpanlessEq::new(cx).ignore_fn().eq_expr(tmp_init, lhs1);
             if SpanlessEq::new(cx).ignore_fn().eq_expr(rhs1, lhs2);
             then {
index 887e9f12712b423a19404fdb1928e75faebe6372..61d496c1f0d3c00eeb332940f6035950d18949e8 100644 (file)
@@ -317,7 +317,7 @@ fn check_ty_rptr(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool, lt: &Lifeti
                     let ltopt = if lt.is_elided() {
                         "".to_owned()
                     } else {
-                        format!("{} ", lt.name.name().as_str())
+                        format!("{} ", lt.name.ident().name.as_str())
                     };
                     let mutopt = if mut_ty.mutbl == Mutability::MutMutable {
                         "mut "
@@ -1993,10 +1993,10 @@ fn visit_expr(&mut self, e: &'tcx Expr) {
                 }
 
                 if match_path(ty_path, &paths::HASHMAP) {
-                    if method.name == "new" {
+                    if method.ident.name == "new" {
                         self.suggestions
                             .insert(e.span, "HashMap::default()".to_string());
-                    } else if method.name == "with_capacity" {
+                    } else if method.ident.name == "with_capacity" {
                         self.suggestions.insert(
                             e.span,
                             format!(
@@ -2006,10 +2006,10 @@ fn visit_expr(&mut self, e: &'tcx Expr) {
                         );
                     }
                 } else if match_path(ty_path, &paths::HASHSET) {
-                    if method.name == "new" {
+                    if method.ident.name == "new" {
                         self.suggestions
                             .insert(e.span, "HashSet::default()".to_string());
-                    } else if method.name == "with_capacity" {
+                    } else if method.ident.name == "with_capacity" {
                         self.suggestions.insert(
                             e.span,
                             format!(
index 1ef20e4a46c931986280825c4300f999e4235c4b..316415d73ad2a676df1c456571270d8d6033978a 100644 (file)
@@ -57,7 +57,7 @@ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
                 }
             },
 
-            hir::ExprMethodCall(ref path, _, ref args) => match &*path.name.as_str() {
+            hir::ExprMethodCall(ref path, _, ref args) => match &*path.ident.as_str() {
                 "expect" | "unwrap" | "unwrap_or" | "unwrap_or_else" => {
                     check_method_call(cx, &args[0], expr);
                 },
@@ -71,7 +71,7 @@ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
 
 fn check_method_call(cx: &LateContext, call: &hir::Expr, expr: &hir::Expr) {
     if let hir::ExprMethodCall(ref path, _, _) = call.node {
-        let symbol = &*path.name.as_str();
+        let symbol = &*path.ident.as_str();
         if match_trait_method(cx, call, &paths::IO_READ) && symbol == "read" {
             span_lint(
                 cx,
index ca3000326750cc23a0781ac36f4f6d18b58577b3..5c5550ed30fb2e675a3059f6b1d13e941a11ea37 100644 (file)
@@ -70,10 +70,10 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> {
     fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
         match expr.node {
             hir::ExprBreak(destination, _) | hir::ExprContinue(destination) => if let Some(label) = destination.label {
-                self.labels.remove(&label.name.as_str());
+                self.labels.remove(&label.ident.as_str());
             },
             hir::ExprLoop(_, Some(label), _) | hir::ExprWhile(_, _, Some(label)) => {
-                self.labels.insert(label.name.as_str(), expr.span);
+                self.labels.insert(label.ident.as_str(), expr.span);
             },
             _ => (),
         }
index 7355b38fd6bf61cd65e6857b76188ad6fa84e45d..b8e34cc66e16e15d1e68e4b5d025433dab8061ad 100644 (file)
@@ -95,7 +95,7 @@ fn collect_unwrap_info<'a, 'tcx: 'a>(
             if let Expr_::ExprPath(QPath::Resolved(None, path)) = &args[0].node;
             let ty = cx.tables.expr_ty(&args[0]);
             if match_type(cx, ty, &paths::OPTION) || match_type(cx, ty, &paths::RESULT);
-            let name = method_name.name.as_str();
+            let name = method_name.ident.as_str();
             if ["is_some", "is_none", "is_ok", "is_err"].contains(&&*name);
             then {
                 assert!(args.len() == 1);
@@ -142,8 +142,8 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
             if_chain! {
                 if let Expr_::ExprMethodCall(ref method_name, _, ref args) = expr.node;
                 if let Expr_::ExprPath(QPath::Resolved(None, ref path)) = args[0].node;
-                if ["unwrap", "unwrap_err"].contains(&&*method_name.name.as_str());
-                let call_to_unwrap = method_name.name == "unwrap";
+                if ["unwrap", "unwrap_err"].contains(&&*method_name.ident.as_str());
+                let call_to_unwrap = method_name.ident.name == "unwrap";
                 if let Some(unwrappable) = self.unwrappables.iter()
                     .find(|u| u.ident.def == path.def);
                 then {
@@ -154,7 +154,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
                             expr.span,
                             &format!("You checked before that `{}()` cannot fail. \
                             Instead of checking and unwrapping, it's better to use `if let` or `match`.",
-                            method_name.name),
+                            method_name.ident.name),
                             |db| { db.span_label(unwrappable.check.span, "the check is happening here"); },
                         );
                     } else {
@@ -163,7 +163,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
                             PANICKING_UNWRAP,
                             expr.span,
                             &format!("This call to `{}()` will always panic.",
-                            method_name.name),
+                            method_name.ident.name),
                             |db| { db.span_label(unwrappable.check.span, "because of this check"); },
                         );
                     }
index 170db6ceabb6b804e072842c84b17a0fded517bb..10b69852ba53c54ca42ff52f8f0d1a0fa5fd2d51 100644 (file)
@@ -88,7 +88,7 @@ struct UseSelfVisitor<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
     fn visit_path(&mut self, path: &'tcx Path, _id: NodeId) {
-        if self.item_path.def == path.def && path.segments.last().expect(SEGMENTS_MSG).name != SelfType.name() {
+        if self.item_path.def == path.def && path.segments.last().expect(SEGMENTS_MSG).ident.name != SelfType.name() {
             span_lint_and_then(self.cx, USE_SELF, path.span, "unnecessary structure name repetition", |db| {
                 db.span_suggestion(path.span, "use the applicable keyword", "Self".to_owned());
             });
index df6a06bc4784926475b670850dffab178da99bd7..520c30b03c0fee102737e2387236ffc09d11380d 100644 (file)
@@ -395,7 +395,7 @@ fn visit_expr(&mut self, expr: &Expr) {
                 let obj_pat = self.next("object");
                 let field_name_pat = self.next("field_name");
                 println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current);
-                println!("    if {}.node.as_str() == {:?}", field_name_pat, field_ident.name.as_str());
+                println!("    if {}.node.as_str() == {:?}", field_name_pat, field_ident.as_str());
                 self.current = obj_pat;
                 self.visit_expr(object);
             },
@@ -487,7 +487,7 @@ fn visit_pat(&mut self, pat: &Pat) {
         let current = format!("{}.node", self.current);
         match pat.node {
             PatKind::Wild => println!("Wild = {};", current),
-            PatKind::Binding(anno, _, name, ref sub) => {
+            PatKind::Binding(anno, _, ident, ref sub) => {
                 let anno_pat = match anno {
                     BindingAnnotation::Unannotated => "BindingAnnotation::Unannotated",
                     BindingAnnotation::Mutable => "BindingAnnotation::Mutable",
@@ -503,7 +503,7 @@ fn visit_pat(&mut self, pat: &Pat) {
                 } else {
                     println!("Binding({}, _, {}, None) = {};", anno_pat, name_pat, current);
                 }
-                println!("    if {}.node.as_str() == \"{}\";", name_pat, name.node.as_str());
+                println!("    if {}.node.as_str() == \"{}\";", name_pat, ident.as_str());
             }
             PatKind::Struct(ref path, ref fields, ignore) => {
                 let path_pat = self.next("path");
@@ -671,7 +671,7 @@ fn print_path(path: &QPath, first: &mut bool) {
             } else {
                 print!(", ");
             }
-            print!("{:?}", segment.name.as_str());
+            print!("{:?}", segment.ident.as_str());
         },
         QPath::TypeRelative(ref ty, ref segment) => match ty.node {
             hir::Ty_::TyPath(ref inner_path) => {
@@ -681,7 +681,7 @@ fn print_path(path: &QPath, first: &mut bool) {
                 } else {
                     print!(", ");
                 }
-                print!("{:?}", segment.name.as_str());
+                print!("{:?}", segment.ident.as_str());
             },
             ref other => print!("/* unimplemented: {:?}*/", other),
         },
index ee6b004dc6cbd4b158cb105e8c8d40e946718708..f95fb046b4978b15aae1c1db03713da7db19b663 100644 (file)
@@ -77,7 +77,7 @@ pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
         match (&left.node, &right.node) {
             (&ExprAddrOf(l_mut, ref le), &ExprAddrOf(r_mut, ref re)) => l_mut == r_mut && self.eq_expr(le, re),
             (&ExprContinue(li), &ExprContinue(ri)) => {
-                both(&li.label, &ri.label, |l, r| l.name.as_str() == r.name.as_str())
+                both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
             },
             (&ExprAssign(ref ll, ref lr), &ExprAssign(ref rl, ref rr)) => self.eq_expr(ll, rl) && self.eq_expr(lr, rr),
             (&ExprAssignOp(ref lo, ref ll, ref lr), &ExprAssignOp(ref ro, ref rl, ref rr)) => {
@@ -91,7 +91,7 @@ pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
                     })
             },
             (&ExprBreak(li, ref le), &ExprBreak(ri, ref re)) => {
-                both(&li.label, &ri.label, |l, r| l.name.as_str() == r.name.as_str())
+                both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
                     && both(le, re, |l, r| self.eq_expr(l, r))
             },
             (&ExprBox(ref l), &ExprBox(ref r)) => self.eq_expr(l, r),
@@ -109,7 +109,7 @@ pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
             },
             (&ExprLit(ref l), &ExprLit(ref r)) => l.node == r.node,
             (&ExprLoop(ref lb, ref ll, ref lls), &ExprLoop(ref rb, ref rl, ref rls)) => {
-                lls == rls && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.name.as_str() == r.name.as_str())
+                lls == rls && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.as_str() == r.ident.as_str())
             },
             (&ExprMatch(ref le, ref la, ref ls), &ExprMatch(ref re, ref ra, ref rs)) => {
                 ls == rs && self.eq_expr(le, re) && over(la, ra, |l, r| {
@@ -138,7 +138,7 @@ pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
             (&ExprUnary(l_op, ref le), &ExprUnary(r_op, ref re)) => l_op == r_op && self.eq_expr(le, re),
             (&ExprArray(ref l), &ExprArray(ref r)) => self.eq_exprs(l, r),
             (&ExprWhile(ref lc, ref lb, ref ll), &ExprWhile(ref rc, ref rb, ref rl)) => {
-                self.eq_expr(lc, rc) && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.name.as_str() == r.name.as_str())
+                self.eq_expr(lc, rc) && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.as_str() == r.ident.as_str())
             },
             _ => false,
         }
@@ -172,7 +172,7 @@ pub fn eq_pat(&mut self, left: &Pat, right: &Pat) -> bool {
                 self.eq_qpath(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs
             },
             (&PatKind::Binding(ref lb, _, ref li, ref lp), &PatKind::Binding(ref rb, _, ref ri, ref rp)) => {
-                lb == rb && li.node.as_str() == ri.node.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
+                lb == rb && li.name.as_str() == ri.name.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
             },
             (&PatKind::Path(ref l), &PatKind::Path(ref r)) => self.eq_qpath(l, r),
             (&PatKind::Lit(ref l), &PatKind::Lit(ref r)) => self.eq_expr(l, r),
@@ -228,7 +228,7 @@ fn eq_path_parameters(&mut self, left: &GenericArgs, right: &GenericArgs) -> boo
     fn eq_path_segment(&mut self, left: &PathSegment, right: &PathSegment) -> bool {
         // The == of idents doesn't work with different contexts,
         // we have to be explicit about hygiene
-        if left.name.as_str() != right.name.as_str() {
+        if left.ident.as_str() != right.ident.as_str() {
             return false;
         }
         match (&left.args, &right.args) {
@@ -268,7 +268,7 @@ fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool {
     }
 
     fn eq_type_binding(&mut self, left: &TypeBinding, right: &TypeBinding) -> bool {
-        left.name == right.name && self.eq_ty(&left.ty, &right.ty)
+        left.ident.name == right.ident.name && self.eq_ty(&left.ty, &right.ty)
     }
 }
 
@@ -356,7 +356,7 @@ pub fn hash_expr(&mut self, e: &Expr) {
                 let c: fn(_) -> _ = ExprContinue;
                 c.hash(&mut self.s);
                 if let Some(i) = i.label {
-                    self.hash_name(i.name);
+                    self.hash_name(i.ident.name);
                 }
             },
             ExprYield(ref e) => {
@@ -393,7 +393,7 @@ pub fn hash_expr(&mut self, e: &Expr) {
                 let c: fn(_, _) -> _ = ExprBreak;
                 c.hash(&mut self.s);
                 if let Some(i) = i.label {
-                    self.hash_name(i.name);
+                    self.hash_name(i.ident.name);
                 }
                 if let Some(ref j) = *j {
                     self.hash_expr(&*j);
@@ -457,7 +457,7 @@ pub fn hash_expr(&mut self, e: &Expr) {
                 c.hash(&mut self.s);
                 self.hash_block(b);
                 if let Some(i) = *i {
-                    self.hash_name(i.name);
+                    self.hash_name(i.ident.name);
                 }
             },
             ExprMatch(ref e, ref arms, ref s) => {
@@ -478,7 +478,7 @@ pub fn hash_expr(&mut self, e: &Expr) {
             ExprMethodCall(ref path, ref _tys, ref args) => {
                 let c: fn(_, _, _) -> _ = ExprMethodCall;
                 c.hash(&mut self.s);
-                self.hash_name(path.name);
+                self.hash_name(path.ident.name);
                 self.hash_exprs(args);
             },
             ExprRepeat(ref e, ref l_id) => {
@@ -548,7 +548,7 @@ pub fn hash_expr(&mut self, e: &Expr) {
                 self.hash_expr(cond);
                 self.hash_block(b);
                 if let Some(l) = l {
-                    self.hash_name(l.name);
+                    self.hash_name(l.ident.name);
                 }
             },
         }
@@ -570,7 +570,7 @@ pub fn hash_qpath(&mut self, p: &QPath) {
                 self.hash_path(path);
             },
             QPath::TypeRelative(_, ref path) => {
-                self.hash_name(path.name);
+                self.hash_name(path.ident.name);
             },
         }
         // self.cx.tables.qpath_def(p, id).hash(&mut self.s);
@@ -579,7 +579,7 @@ pub fn hash_qpath(&mut self, p: &QPath) {
     pub fn hash_path(&mut self, p: &Path) {
         p.is_global().hash(&mut self.s);
         for p in &p.segments {
-            self.hash_name(p.name);
+            self.hash_name(p.ident.name);
         }
     }
 
index 9d92147048c3237509f5a12eadb2dc2dcc310b56..b23464c80dee17a639bf3d0271e89a56ed8ecb20 100644 (file)
@@ -50,7 +50,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplI
         if !has_attr(&item.attrs) {
             return;
         }
-        println!("impl item `{}`", item.name);
+        println!("impl item `{}`", item.ident.name);
         match item.vis {
             hir::Visibility::Public => println!("public"),
             hir::Visibility::Crate(_) => println!("visible crate wide"),
@@ -181,7 +181,7 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
         },
         hir::ExprMethodCall(ref path, _, ref args) => {
             println!("{}MethodCall", ind);
-            println!("{}method name: {}", ind, path.name);
+            println!("{}method name: {}", ind, path.ident.name);
             for arg in args {
                 print_expr(cx, arg, indent + 1);
             }
@@ -268,7 +268,7 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
             println!("{}rhs:", ind);
             print_expr(cx, rhs, indent + 1);
         },
-        hir::ExprField(ref e, ref ident) => {
+        hir::ExprField(ref e, ident) => {
             println!("{}Field", ind);
             println!("{}field name: {}", ind, ident.name);
             println!("{}struct expr:", ind);
@@ -417,10 +417,10 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) {
     println!("{}+", ind);
     match pat.node {
         hir::PatKind::Wild => println!("{}Wild", ind),
-        hir::PatKind::Binding(ref mode, _, ref name, ref inner) => {
+        hir::PatKind::Binding(ref mode, _, ident, ref inner) => {
             println!("{}Binding", ind);
             println!("{}mode: {:?}", ind, mode);
-            println!("{}name: {}", ind, name.node);
+            println!("{}name: {}", ind, ident.name);
             if let Some(ref inner) = *inner {
                 println!("{}inner:", ind);
                 print_pat(cx, inner, indent + 1);
index 1de0975ab4216bf7db678d2b22fe3a3c7369ce77..b1b65698eb9602f8d40deeff2000fc93c2760424 100644 (file)
@@ -78,7 +78,7 @@ fn check_crate(&mut self, cx: &EarlyContext, krate: &AstCrate) {
                     if let ItemKind::Mod(ref paths_mod) = paths.node {
                         let mut last_name: Option<LocalInternedString> = None;
                         for item in &paths_mod.items {
-                            let name = item.ident.name.as_str();
+                            let name = item.ident.as_str();
                             if let Some(ref last_name) = last_name {
                                 if **last_name > *name {
                                     span_lint(
@@ -196,7 +196,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
 
     fn visit_path(&mut self, path: &'tcx Path, _: NodeId) {
         if path.segments.len() == 1 {
-            self.output.insert(path.segments[0].name);
+            self.output.insert(path.segments[0].ident.name);
         }
     }
     fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
index faecdba357f50952fbaed1a45293381626698d2d..6765d9afb66d547240f29b6dea433d89e8e4f888 100644 (file)
@@ -175,7 +175,7 @@ pub fn match_trait_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool
 /// Check if an expression references a variable of the given name.
 pub fn match_var(expr: &Expr, var: Name) -> bool {
     if let ExprPath(QPath::Resolved(None, ref path)) = expr.node {
-        if path.segments.len() == 1 && path.segments[0].name == var {
+        if path.segments.len() == 1 && path.segments[0].ident.name == var {
             return true;
         }
     }
@@ -212,7 +212,7 @@ pub fn match_qpath(path: &QPath, segments: &[&str]) -> bool {
         QPath::TypeRelative(ref ty, ref segment) => match ty.node {
             TyPath(ref inner_path) => {
                 !segments.is_empty() && match_qpath(inner_path, &segments[..(segments.len() - 1)])
-                    && segment.name == segments[segments.len() - 1]
+                    && segment.ident.name == segments[segments.len() - 1]
             },
             _ => false,
         },
@@ -224,7 +224,7 @@ pub fn match_path(path: &Path, segments: &[&str]) -> bool {
         .iter()
         .rev()
         .zip(segments.iter().rev())
-        .all(|(a, b)| a.name == *b)
+        .all(|(a, b)| a.ident.name == *b)
 }
 
 /// Match a `Path` against a slice of segment string literals, e.g.
@@ -331,7 +331,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option<Vec<&'a
     for method_name in methods.iter().rev() {
         // method chains are stored last -> first
         if let ExprMethodCall(ref path, _, ref args) = current.node {
-            if path.name == *method_name {
+            if path.ident.name == *method_name {
                 if args.iter().any(|e| in_macro(e.span)) {
                     return None;
                 }
@@ -353,9 +353,9 @@ pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option<Vec<&'a
 pub fn get_item_name(cx: &LateContext, expr: &Expr) -> Option<Name> {
     let parent_id = cx.tcx.hir.get_parent(expr.id);
     match cx.tcx.hir.find(parent_id) {
-        Some(Node::NodeItem(&Item { ref name, .. })) |
-        Some(Node::NodeTraitItem(&TraitItem { ref name, .. })) |
-        Some(Node::NodeImplItem(&ImplItem { ref name, .. })) => Some(*name),
+        Some(Node::NodeItem(&Item { ref name, .. })) => Some(*name),
+        Some(Node::NodeTraitItem(&TraitItem { ident, .. })) |
+        Some(Node::NodeImplItem(&ImplItem { ident, .. })) => Some(ident.name),
         _ => None,
     }
 }
@@ -363,8 +363,8 @@ pub fn get_item_name(cx: &LateContext, expr: &Expr) -> Option<Name> {
 /// Get the name of a `Pat`, if any
 pub fn get_pat_name(pat: &Pat) -> Option<Name> {
     match pat.node {
-        PatKind::Binding(_, _, ref spname, _) => Some(spname.node),
-        PatKind::Path(ref qpath) => single_segment_path(qpath).map(|ps| ps.name),
+        PatKind::Binding(_, _, ref spname, _) => Some(spname.name),
+        PatKind::Path(ref qpath) => single_segment_path(qpath).map(|ps| ps.ident.name),
         PatKind::Box(ref p) | PatKind::Ref(ref p, _) => get_pat_name(&*p),
         _ => None,
     }
@@ -431,7 +431,7 @@ pub fn snippet_block<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'
 pub fn last_line_of_span<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Span {
     let file_map_and_line = cx.sess().codemap().lookup_line(span.lo()).unwrap();
     let line_no = file_map_and_line.line;
-    let line_start = &file_map_and_line.fm.lines.clone().into_inner()[line_no];
+    let line_start = &file_map_and_line.fm.lines[line_no];
     Span::new(*line_start, span.hi(), span.ctxt())
 }
 
@@ -990,7 +990,7 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {
 
 pub fn is_self(slf: &Arg) -> bool {
     if let PatKind::Binding(_, _, name, _) = slf.pat.node {
-        name.node == keywords::SelfValue.name()
+        name.name == keywords::SelfValue.name()
     } else {
         false
     }
@@ -1068,12 +1068,20 @@ pub fn is_allowed(cx: &LateContext, lint: &'static Lint, id: NodeId) -> bool {
 
 pub fn get_arg_name(pat: &Pat) -> Option<ast::Name> {
     match pat.node {
-        PatKind::Binding(_, _, name, None) => Some(name.node),
+        PatKind::Binding(_, _, ident, None) => Some(ident.name),
         PatKind::Ref(ref subpat, _) => get_arg_name(subpat),
         _ => None,
     }
 }
 
+pub fn get_arg_ident(pat: &Pat) -> Option<ast::Ident> {
+    match pat.node {
+        PatKind::Binding(_, _, ident, None) => Some(ident),
+        PatKind::Ref(ref subpat, _) => get_arg_ident(subpat),
+        _ => None,
+    }
+}
+
 pub fn int_bits(tcx: TyCtxt, ity: ast::IntTy) -> u64 {
     layout::Integer::from_attr(tcx, attr::IntType::SignedInt(ity)).size().bits()
 }
index dd286a69547cc50df31e03b8d6a6a3361bb21616..09ec90ac63fcd85b3b7b7889b69f65ea98ca5b2d 100644 (file)
@@ -56,12 +56,12 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
         }
         if let ExprMethodCall(ref seg, _, ref args) = expr.node {
             if args.len() == 1 && match_var(&args[0], self.name) {
-                if seg.name == "capacity" {
+                if seg.ident.name == "capacity" {
                     self.abort = true;
                     return;
                 }
                 for &(fn_name, suffix) in self.replace {
-                    if seg.name == fn_name {
+                    if seg.ident.name == fn_name {
                         self.spans
                             .push((expr.span, snippet(self.cx, args[0].span, "_") + suffix));
                         return;
index 274dd952f098298ab82898f101e71147c2a5dced..86c95dbcc56458fba177ed7de8a7b31fe3f390a1 100644 (file)
@@ -186,7 +186,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
             },
             // write!()
             ExprMethodCall(ref fun, _, ref args) => {
-                if fun.name == "write_fmt" {
+                if fun.ident.name == "write_fmt" {
                     check_write_variants(cx, expr, args);
                 }
             },
@@ -471,13 +471,13 @@ pub fn check_unformatted(format_field: &Expr) -> bool {
         if let ExprStruct(_, ref fields, _) = format_field.node;
         if let Some(width_field) = fields.iter().find(|f| f.ident.name == "width");
         if let ExprPath(ref qpath) = width_field.expr.node;
-        if last_path_segment(qpath).name == "Implied";
+        if last_path_segment(qpath).ident.name == "Implied";
         if let Some(align_field) = fields.iter().find(|f| f.ident.name == "align");
         if let ExprPath(ref qpath) = align_field.expr.node;
-        if last_path_segment(qpath).name == "Unknown";
+        if last_path_segment(qpath).ident.name == "Unknown";
         if let Some(precision_field) = fields.iter().find(|f| f.ident.name == "precision");
         if let ExprPath(ref qpath_precision) = precision_field.expr.node;
-        if last_path_segment(qpath_precision).name == "Implied";
+        if last_path_segment(qpath_precision).ident.name == "Implied";
         then {
             return true;
         }