Merge pull request #1931 from rust-lang-nursery/move_links

Change all links to reflect the move to rust-lang-nursery
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a05e95..21fa487 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,9 @@
 # Change Log
 All notable changes to this project will be documented in this file.
 
+## 0.0.152
+* Update to *rustc 1.21.0-nightly (df511d554 2017-08-14)*
+
 ## 0.0.151
 * Update to *rustc 1.21.0-nightly (13d94d5fa 2017-08-10)*
 
diff --git a/Cargo.toml b/Cargo.toml
index 3507c13..237ab4f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "clippy"
-version = "0.0.151"
+version = "0.0.152"
 authors = [
 	"Manish Goregaokar <manishsmail@gmail.com>",
 	"Andre Bogus <bogusandre@gmail.com>",
@@ -31,7 +31,7 @@
 
 [dependencies]
 # begin automatic update
-clippy_lints = { version = "0.0.151", path = "clippy_lints" }
+clippy_lints = { version = "0.0.152", path = "clippy_lints" }
 # end automatic update
 cargo_metadata = "0.2"
 
diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml
index 850933c..e545b13 100644
--- a/clippy_lints/Cargo.toml
+++ b/clippy_lints/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "clippy_lints"
 # begin automatic update
-version = "0.0.151"
+version = "0.0.152"
 # end automatic update
 authors = [
 	"Manish Goregaokar <manishsmail@gmail.com>",
diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs
index a52c4d9..86d7222 100644
--- a/clippy_lints/src/attrs.rs
+++ b/clippy_lints/src/attrs.rs
@@ -215,7 +215,7 @@
         ExprBreak(_, None) => false,
         ExprCall(ref path_expr, _) => {
             if let ExprPath(ref qpath) = path_expr.node {
-                let fun_id = tables.qpath_def(qpath, path_expr.id).def_id();
+                let fun_id = tables.qpath_def(qpath, path_expr.hir_id).def_id();
                 !match_def_path(tcx, fun_id, &paths::BEGIN_PANIC)
             } else {
                 true
diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs
index 64f007b..6e5a182 100644
--- a/clippy_lints/src/bit_mask.rs
+++ b/clippy_lints/src/bit_mask.rs
@@ -126,7 +126,7 @@
                                "bit mask could be simplified with a call to `trailing_zeros`",
                                |db| {
                 let sugg = Sugg::hir(cx, left1, "...").maybe_par();
-                db.span_suggestion(e.span, "try", format!("{}.trailing_zeros() > {}", sugg, n.count_ones()));
+                db.span_suggestion(e.span, "try", format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()));
             });
         }}
     }
@@ -318,7 +318,7 @@
             }
         },
         ExprPath(ref qpath) => {
-            let def = cx.tables.qpath_def(qpath, lit.id);
+            let def = cx.tables.qpath_def(qpath, lit.hir_id);
             if let Def::Const(def_id) = def {
                 lookup_const_by_id(cx.tcx, cx.param_env.and((def_id, Substs::empty()))).and_then(|(l, _ty)| {
                     let body = if let Some(id) = cx.tcx.hir.as_local_node_id(l) {
diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs
index 4c67b26..7c7dbe8 100644
--- a/clippy_lints/src/booleans.rs
+++ b/clippy_lints/src/booleans.rs
@@ -122,6 +122,7 @@
                     let mk_expr = |op| {
                         Expr {
                             id: DUMMY_NODE_ID,
+                            hir_id: DUMMY_HIR_ID,
                             span: DUMMY_SP,
                             attrs: ThinVec::new(),
                             node: ExprBinary(dummy_spanned(op), lhs.clone(), rhs.clone()),
@@ -411,7 +412,7 @@
         match e.node {
             ExprBinary(binop, _, _) if binop.node == BiOr || binop.node == BiAnd => self.bool_expr(e),
             ExprUnary(UnNot, ref inner) => {
-                if self.cx.tables.node_types[&inner.id].is_bool() {
+                if self.cx.tables.node_types()[inner.hir_id].is_bool() {
                     self.bool_expr(e);
                 } else {
                     walk_expr(self, e);
diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs
index 095fcf0..2a6fa05 100644
--- a/clippy_lints/src/consts.rs
+++ b/clippy_lints/src/consts.rs
@@ -12,7 +12,7 @@
 use std::hash::{Hash, Hasher};
 use std::mem;
 use std::rc::Rc;
-use syntax::ast::{FloatTy, LitKind, StrStyle, NodeId};
+use syntax::ast::{FloatTy, LitKind, StrStyle};
 use syntax::ptr::P;
 
 #[derive(Debug, Copy, Clone)]
@@ -249,7 +249,7 @@
     /// simple constant folding: Insert an expression, get a constant or none.
     fn expr(&mut self, e: &Expr) -> Option<Constant> {
         match e.node {
-            ExprPath(ref qpath) => self.fetch_path(qpath, e.id),
+            ExprPath(ref qpath) => self.fetch_path(qpath, e.hir_id),
             ExprBlock(ref block) => self.block(block),
             ExprIf(ref cond, ref then, ref otherwise) => self.ifthenelse(cond, then, otherwise),
             ExprLit(ref lit) => Some(lit_to_constant(&lit.node, self.tcx, self.tables.expr_ty(e))),
@@ -284,7 +284,7 @@
     }
 
     /// lookup a possibly constant expression from a ExprPath
-    fn fetch_path(&mut self, qpath: &QPath, id: NodeId) -> Option<Constant> {
+    fn fetch_path(&mut self, qpath: &QPath, id: HirId) -> Option<Constant> {
         let def = self.tables.qpath_def(qpath, id);
         match def {
             Def::Const(def_id) |
diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs
index f2ee629..c7593a1 100644
--- a/clippy_lints/src/cyclomatic_complexity.rs
+++ b/clippy_lints/src/cyclomatic_complexity.rs
@@ -71,7 +71,7 @@
             returns,
             ..
         } = helper;
-        let ret_ty = cx.tables.node_id_to_type(expr.id);
+        let ret_ty = cx.tables.node_id_to_type(expr.hir_id);
         let ret_adjust = if match_type(cx, ret_ty, &paths::RESULT) {
             returns
         } else {
@@ -160,7 +160,7 @@
             },
             ExprCall(ref callee, _) => {
                 walk_expr(self, e);
-                let ty = self.cx.tables.node_id_to_type(callee.id);
+                let ty = self.cx.tables.node_id_to_type(callee.hir_id);
                 match ty.sty {
                     ty::TyFnDef(..) | ty::TyFnPtr(_) => {
                         let sig = ty.fn_sig(self.cx.tcx);
diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs
index b02333b..dfa8ddb 100644
--- a/clippy_lints/src/drop_forget_ref.rs
+++ b/clippy_lints/src/drop_forget_ref.rs
@@ -120,7 +120,7 @@
             let ExprPath(ref qpath) = path.node,
             args.len() == 1,
         ], {
-            let def_id = cx.tables.qpath_def(qpath, path.id).def_id();
+            let def_id = cx.tables.qpath_def(qpath, path.hir_id).def_id();
             let lint;
             let msg;
             let arg = &args[0];
diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs
index 8110976..549b621 100644
--- a/clippy_lints/src/eval_order_dependence.rs
+++ b/clippy_lints/src/eval_order_dependence.rs
@@ -67,7 +67,7 @@
                 if let ExprPath(ref qpath) = lhs.node {
                     if let QPath::Resolved(_, ref path) = *qpath {
                         if path.segments.len() == 1 {
-                            let var = cx.tables.qpath_def(qpath, lhs.id).def_id();
+                            let var = cx.tables.qpath_def(qpath, lhs.hir_id).def_id();
                             let mut visitor = ReadVisitor {
                                 cx: cx,
                                 var: var,
@@ -304,7 +304,7 @@
         match expr.node {
             ExprPath(ref qpath) => {
                 if let QPath::Resolved(None, ref path) = *qpath {
-                    if path.segments.len() == 1 && self.cx.tables.qpath_def(qpath, expr.id).def_id() == self.var {
+                    if path.segments.len() == 1 && self.cx.tables.qpath_def(qpath, expr.hir_id).def_id() == self.var {
                         if is_in_assignment_position(self.cx, expr) {
                             // This is a write, not a read.
                         } else {
diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs
index 16dced9..fb2e04a 100644
--- a/clippy_lints/src/format.rs
+++ b/clippy_lints/src/format.rs
@@ -47,7 +47,7 @@
                     if_let_chain!{[
                         let ExprPath(ref qpath) = fun.node,
                         args.len() == 2,
-                        match_def_path(cx.tcx, resolve_node(cx, qpath, fun.id).def_id(), &paths::FMT_ARGUMENTS_NEWV1),
+                        match_def_path(cx.tcx, resolve_node(cx, qpath, fun.hir_id).def_id(), &paths::FMT_ARGUMENTS_NEWV1),
                         // ensure the format string is `"{..}"` with only one argument and no text
                         check_static_str(cx, &args[0]),
                         // ensure the format argument is `{}` ie. Display with no fancy option
@@ -130,7 +130,7 @@
         let ExprCall(_, ref args) = exprs[0].node,
         args.len() == 2,
         let ExprPath(ref qpath) = args[1].node,
-        match_def_path(cx.tcx, resolve_node(cx, qpath, args[1].id).def_id(), &paths::DISPLAY_FMT_METHOD),
+        match_def_path(cx.tcx, resolve_node(cx, qpath, args[1].hir_id).def_id(), &paths::DISPLAY_FMT_METHOD),
     ], {
         let ty = walk_ptrs_ty(cx.tables.pat_ty(&pat[0]));
 
diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs
index e45ab55..1bb8780 100644
--- a/clippy_lints/src/functions.rs
+++ b/clippy_lints/src/functions.rs
@@ -187,7 +187,7 @@
                 }
             },
             hir::ExprMethodCall(_, _, ref args) => {
-                let def_id = self.cx.tables.type_dependent_defs[&expr.id].def_id();
+                let def_id = self.cx.tables.type_dependent_defs()[expr.hir_id].def_id();
                 let base_type = self.cx.tcx.type_of(def_id);
 
                 if type_is_unsafe_function(self.cx, base_type) {
@@ -210,7 +210,7 @@
 impl<'a, 'tcx: 'a> DerefVisitor<'a, 'tcx> {
     fn check_arg(&self, ptr: &hir::Expr) {
         if let hir::ExprPath(ref qpath) = ptr.node {
-            let def = self.cx.tables.qpath_def(qpath, ptr.id);
+            let def = self.cx.tables.qpath_def(qpath, ptr.hir_id);
             if self.ptrs.contains(&def.def_id()) {
                 span_lint(
                     self.cx,
diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs
index ecd1842..64ba8ad 100644
--- a/clippy_lints/src/let_if_seq.rs
+++ b/clippy_lints/src/let_if_seq.rs
@@ -139,7 +139,7 @@
     fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
         if_let_chain! {[
             let hir::ExprPath(ref qpath) = expr.node,
-            self.id == self.cx.tables.qpath_def(qpath, expr.id).def_id(),
+            self.id == self.cx.tables.qpath_def(qpath, expr.hir_id).def_id(),
         ], {
             self.used = true;
             return;
@@ -162,7 +162,7 @@
         let hir::StmtSemi(ref expr, _) = expr.node,
         let hir::ExprAssign(ref var, ref value) = expr.node,
         let hir::ExprPath(ref qpath) = var.node,
-        decl == cx.tables.qpath_def(qpath, var.id).def_id(),
+        decl == cx.tables.qpath_def(qpath, var.hir_id).def_id(),
     ], {
         let mut v = UsedVisitor {
             cx: cx,
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 18759fb..a8f1b16 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -148,6 +148,7 @@
 pub mod unsafe_removed_from_name;
 pub mod unused_io_amount;
 pub mod unused_label;
+pub mod use_self;
 pub mod vec;
 pub mod zero_div_zero;
 // end lints modules, do not remove this comment, it’s used in `update_lints`
@@ -319,6 +320,7 @@
     reg.register_late_lint_pass(box should_assert_eq::ShouldAssertEq);
     reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
     reg.register_early_lint_pass(box literal_digit_grouping::LiteralDigitGrouping);
+    reg.register_late_lint_pass(box use_self::UseSelf);
 
     reg.register_lint_group("clippy_restrictions", vec![
         arithmetic::FLOAT_ARITHMETIC,
diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs
index 21b8bf6..507373f 100644
--- a/clippy_lints/src/lifetimes.rs
+++ b/clippy_lints/src/lifetimes.rs
@@ -284,7 +284,8 @@
         let last_path_segment = &last_path_segment(qpath).parameters;
         if let AngleBracketedParameters(ref params) = *last_path_segment {
             if params.lifetimes.is_empty() {
-                match self.cx.tables.qpath_def(qpath, ty.id) {
+                let hir_id = self.cx.tcx.hir.node_to_hir_id(ty.id);
+                match self.cx.tables.qpath_def(qpath, hir_id) {
                     Def::TyAlias(def_id) |
                     Def::Struct(def_id) => {
                         let generics = self.cx.tcx.generics_of(def_id);
diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs
index 25015cb..439a82e 100644
--- a/clippy_lints/src/loops.rs
+++ b/clippy_lints/src/loops.rs
@@ -801,8 +801,8 @@
                     lint_iter_method(cx, args, arg, method_name);
                 }
             } else if method_name == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) {
-                let def_id = cx.tables.type_dependent_defs[&arg.id].def_id();
-                let substs = cx.tables.node_substs(arg.id);
+                let def_id = cx.tables.type_dependent_defs()[arg.hir_id].def_id();
+                let substs = cx.tables.node_substs(arg.hir_id);
                 let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
 
                 let fn_arg_tys = method_type.fn_sig(cx.tcx).inputs();
@@ -1053,13 +1053,13 @@
             let QPath::Resolved(None, ref path) = *qpath,
             path.segments.len() == 1,
             // our variable!
-            self.cx.tables.qpath_def(qpath, expr.id).def_id() == self.var,
+            self.cx.tables.qpath_def(qpath, expr.hir_id).def_id() == self.var,
             // the indexed container is referenced by a name
             let ExprPath(ref seqpath) = seqexpr.node,
             let QPath::Resolved(None, ref seqvar) = *seqpath,
             seqvar.segments.len() == 1,
         ], {
-            let def = self.cx.tables.qpath_def(seqpath, seqexpr.id);
+            let def = self.cx.tables.qpath_def(seqpath, seqexpr.hir_id);
             match def {
                 Def::Local(..) | Def::Upvar(..) => {
                     let def_id = def.def_id();
@@ -1085,7 +1085,7 @@
             let QPath::Resolved(None, ref path) = *qpath,
             path.segments.len() == 1,
         ], {
-            if self.cx.tables.qpath_def(qpath, expr.id).def_id() == self.var {
+            if self.cx.tables.qpath_def(qpath, expr.hir_id).def_id() == self.var {
                 // we are not indexing anything, record that
                 self.nonindex = true;
             } else {
@@ -1376,7 +1376,7 @@
 
 fn var_def_id(cx: &LateContext, expr: &Expr) -> Option<NodeId> {
     if let ExprPath(ref qpath) = expr.node {
-        let path_res = cx.tables.qpath_def(qpath, expr.id);
+        let path_res = cx.tables.qpath_def(qpath, expr.hir_id);
         if let Def::Local(def_id) = path_res {
             let node_id = cx.tcx.hir.as_local_node_id(def_id).expect(
                 "That DefId should be valid",
diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs
index 280b51b..edf4777 100644
--- a/clippy_lints/src/mem_forget.rs
+++ b/clippy_lints/src/mem_forget.rs
@@ -32,7 +32,7 @@
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
         if let ExprCall(ref path_expr, ref args) = e.node {
             if let ExprPath(ref qpath) = path_expr.node {
-                let def_id = cx.tables.qpath_def(qpath, path_expr.id).def_id();
+                let def_id = cx.tables.qpath_def(qpath, path_expr.hir_id).def_id();
                 if match_def_path(cx.tcx, def_id, &paths::MEM_FORGET) {
                     let forgot_ty = cx.tables.expr_ty(&args[0]);
 
diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs
index c04fdde..a50d77f 100644
--- a/clippy_lints/src/methods.rs
+++ b/clippy_lints/src/methods.rs
@@ -898,7 +898,7 @@
         let hir::ExprCall(ref fun, ref args) = new.node,
         args.len() == 1,
         let hir::ExprPath(ref path) = fun.node,
-        let Def::Method(did) = cx.tables.qpath_def(path, fun.id),
+        let Def::Method(did) = cx.tables.qpath_def(path, fun.hir_id),
         match_def_path(cx.tcx, did, &paths::CSTRING_NEW)
     ], {
         span_lint_and_then(cx, TEMPORARY_CSTRING_AS_PTR, expr.span,
diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs
index 2c6553e..a86b2b3 100644
--- a/clippy_lints/src/minmax.rs
+++ b/clippy_lints/src/minmax.rs
@@ -62,7 +62,7 @@
 fn min_max<'a>(cx: &LateContext, expr: &'a Expr) -> Option<(MinMax, Constant, &'a Expr)> {
     if let ExprCall(ref path, ref args) = expr.node {
         if let ExprPath(ref qpath) = path.node {
-            let def_id = cx.tables.qpath_def(qpath, path.id).def_id();
+            let def_id = cx.tables.qpath_def(qpath, path.hir_id).def_id();
 
             if match_def_path(cx.tcx, def_id, &paths::CMP_MIN) {
                 fetch_const(cx, args, MinMax::Min)
diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs
index 67b0b1e..ef42bfe 100644
--- a/clippy_lints/src/misc.rs
+++ b/clippy_lints/src/misc.rs
@@ -361,7 +361,7 @@
                     binding != "_result" && // FIXME: #944
                     is_used(cx, expr) &&
                     // don't lint if the declaration is in a macro
-                    non_macro_local(cx, &cx.tables.qpath_def(qpath, expr.id))
+                    non_macro_local(cx, &cx.tables.qpath_def(qpath, expr.hir_id))
                 {
                     Some(binding)
                 } else {
diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs
index 0c0c8f4..6a7b45b 100644
--- a/clippy_lints/src/mut_reference.rs
+++ b/clippy_lints/src/mut_reference.rs
@@ -47,8 +47,8 @@
                 }
             },
             ExprMethodCall(ref path, _, ref arguments) => {
-                let def_id = cx.tables.type_dependent_defs[&e.id].def_id();
-                let substs = cx.tables.node_substs(e.id);
+                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())
             },
diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs
index c57df46..782b403 100644
--- a/clippy_lints/src/no_effect.rs
+++ b/clippy_lints/src/no_effect.rs
@@ -69,7 +69,7 @@
         },
         Expr_::ExprCall(ref callee, ref args) => {
             if let Expr_::ExprPath(ref qpath) = callee.node {
-                let def = cx.tables.qpath_def(qpath, callee.id);
+                let def = cx.tables.qpath_def(qpath, callee.hir_id);
                 match def {
                     Def::Struct(..) |
                     Def::Variant(..) |
@@ -165,7 +165,7 @@
         },
         Expr_::ExprCall(ref callee, ref args) => {
             if let Expr_::ExprPath(ref qpath) = callee.node {
-                let def = cx.tables.qpath_def(qpath, callee.id);
+                let def = cx.tables.qpath_def(qpath, callee.hir_id);
                 match def {
                     Def::Struct(..) |
                     Def::Variant(..) |
diff --git a/clippy_lints/src/panic.rs b/clippy_lints/src/panic.rs
index 9c1c6be..e9e529c 100644
--- a/clippy_lints/src/panic.rs
+++ b/clippy_lints/src/panic.rs
@@ -40,7 +40,7 @@
             let ExprCall(ref fun, ref params) = ex.node,
             params.len() == 2,
             let ExprPath(ref qpath) = fun.node,
-            match_def_path(cx.tcx, resolve_node(cx, qpath, fun.id).def_id(), &paths::BEGIN_PANIC),
+            match_def_path(cx.tcx, resolve_node(cx, qpath, fun.hir_id).def_id(), &paths::BEGIN_PANIC),
             let ExprLit(ref lit) = params[0].node,
             is_direct_expn_of(expr.span, "panic").is_some(),
             let LitKind::Str(ref string, _) = lit.node,
diff --git a/clippy_lints/src/print.rs b/clippy_lints/src/print.rs
index bf734cc..4a427fc 100644
--- a/clippy_lints/src/print.rs
+++ b/clippy_lints/src/print.rs
@@ -73,7 +73,7 @@
             let ExprCall(ref fun, ref args) = expr.node,
             let ExprPath(ref qpath) = fun.node,
         ], {
-            let fun = resolve_node(cx, qpath, fun.id);
+            let fun = resolve_node(cx, qpath, fun.hir_id);
             let fun_id = fun.def_id();
 
             // Search for `std::io::_print(..)` which is unique in a
@@ -97,7 +97,7 @@
                         let ExprCall(ref args_fun, ref args_args) = args[0].node,
                         let ExprPath(ref qpath) = args_fun.node,
                         match_def_path(cx.tcx,
-                                       resolve_node(cx, qpath, args_fun.id).def_id(),
+                                       resolve_node(cx, qpath, args_fun.hir_id).def_id(),
                                        &paths::FMT_ARGUMENTS_NEWV1),
                         args_args.len() == 2,
                         let ExprAddrOf(_, ref match_expr) = args_args[1].node,
@@ -125,7 +125,7 @@
             // `::std::fmt::ArgumentV1::new(__arg0, ::std::fmt::Debug::fmt)`
             else if args.len() == 2 && match_def_path(cx.tcx, fun_id, &paths::FMT_ARGUMENTV1_NEW) {
                 if let ExprPath(ref qpath) = args[1].node {
-                    let def_id = cx.tables.qpath_def(qpath, args[1].id).def_id();
+                    let def_id = cx.tables.qpath_def(qpath, args[1].hir_id).def_id();
                     if match_def_path(cx.tcx, def_id, &paths::DEBUG_FMT_METHOD) && !is_in_debug_impl(cx, expr) &&
                        is_expn_of(expr.span, "panic").is_none() {
                         span_lint(cx, USE_DEBUG, args[0].span, "use of `Debug`-based formatting");
diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs
index 4feeb6d..4241dd9 100644
--- a/clippy_lints/src/regex.rs
+++ b/clippy_lints/src/regex.rs
@@ -118,7 +118,7 @@
             let ExprPath(ref qpath) = fun.node,
             args.len() == 1,
         ], {
-            let def_id = cx.tables.qpath_def(qpath, fun.id).def_id();
+            let def_id = cx.tables.qpath_def(qpath, fun.hir_id).def_id();
             if match_def_path(cx.tcx, def_id, &paths::REGEX_NEW) ||
                match_def_path(cx.tcx, def_id, &paths::REGEX_BUILDER_NEW) {
                 check_regex(cx, &args[0], true);
diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs
index e80636c..b4857f1 100644
--- a/clippy_lints/src/shadow.rs
+++ b/clippy_lints/src/shadow.rs
@@ -148,7 +148,7 @@
     }
 }
 
-fn is_binding(cx: &LateContext, pat_id: NodeId) -> bool {
+fn is_binding(cx: &LateContext, pat_id: HirId) -> bool {
     let var_ty = cx.tables.node_id_to_type(pat_id);
     match var_ty.sty {
         ty::TyAdt(..) => false,
@@ -167,7 +167,7 @@
     match pat.node {
         PatKind::Binding(_, _, ref ident, ref inner) => {
             let name = ident.node;
-            if is_binding(cx, pat.id) {
+            if is_binding(cx, pat.hir_id) {
                 let mut new_binding = true;
                 for tup in bindings.iter_mut() {
                     if tup.0 == name {
diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs
index 13555e3..bcb03c7 100644
--- a/clippy_lints/src/transmute.rs
+++ b/clippy_lints/src/transmute.rs
@@ -88,7 +88,7 @@
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
         if let ExprCall(ref path_expr, ref args) = e.node {
             if let ExprPath(ref qpath) = path_expr.node {
-                let def_id = cx.tables.qpath_def(qpath, path_expr.id).def_id();
+                let def_id = cx.tables.qpath_def(qpath, path_expr.hir_id).def_id();
 
                 if match_def_path(cx.tcx, def_id, &paths::TRANSMUTE) {
                     let from_ty = cx.tables.expr_ty(&args[0]);
diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs
index 1865826..9d6167c 100644
--- a/clippy_lints/src/types.rs
+++ b/clippy_lints/src/types.rs
@@ -149,7 +149,8 @@
     }
     match ast_ty.node {
         TyPath(ref qpath) if !is_local => {
-            let def = cx.tables.qpath_def(qpath, ast_ty.id);
+            let hir_id = cx.tcx.hir.node_to_hir_id(ast_ty.id);
+            let def = cx.tables.qpath_def(qpath, hir_id);
             if let Some(def_id) = opt_def_id(def) {
                 if Some(def_id) == cx.tcx.lang_items.owned_box() {
                     let last = last_path_segment(qpath);
@@ -157,8 +158,7 @@
                         let PathParameters::AngleBracketedParameters(ref ag) = last.parameters,
                         let Some(vec) = ag.types.get(0),
                         let TyPath(ref qpath) = vec.node,
-                        let def::Def::Struct(..) = cx.tables.qpath_def(qpath, vec.id),
-                        let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, vec.id)),
+                        let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir.node_to_hir_id(vec.id))),
                         match_def_path(cx.tcx, did, &paths::VEC),
                     ], {
                         span_help_and_lint(cx,
@@ -202,7 +202,8 @@
         TyRptr(ref lt, MutTy { ref ty, ref mutbl }) => {
             match ty.node {
                 TyPath(ref qpath) => {
-                    let def = cx.tables.qpath_def(qpath, ast_ty.id);
+                    let hir_id = cx.tcx.hir.node_to_hir_id(ty.id);
+                    let def = cx.tables.qpath_def(qpath, hir_id);
                     if_let_chain! {[
                         let Some(def_id) = opt_def_id(def),
                         Some(def_id) == cx.tcx.lang_items.owned_box(),
diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs
new file mode 100644
index 0000000..2a94d8f
--- /dev/null
+++ b/clippy_lints/src/use_self.rs
@@ -0,0 +1,91 @@
+use rustc::lint::{LintArray, LateLintPass, LateContext, LintPass};
+use rustc::hir::*;
+use rustc::hir::intravisit::{Visitor, walk_path, NestedVisitorMap};
+use utils::span_lint_and_then;
+use syntax::ast::NodeId;
+use syntax_pos::symbol::keywords::SelfType;
+
+/// **What it does:** Checks for unnecessary repetition of structure name when a
+/// replacement with `Self` is applicable.
+///
+/// **Why is this bad?** Unnecessary repetition. Mixed use of `Self` and struct name
+/// feels inconsistent.
+///
+/// **Known problems:** None.
+///
+/// **Example:**
+/// ```rust
+/// struct Foo {}
+/// impl Foo {
+///     fn new() -> Foo {
+///         Foo {}
+///     }
+/// }
+/// ```
+/// could be
+/// ```
+/// struct Foo {}
+/// impl Foo {
+///     fn new() -> Self {
+///         Self {}
+///     }
+/// }
+/// ```
+declare_lint! {
+    pub USE_SELF,
+    Allow,
+    "Unnecessary structure name repetition whereas `Self` is applicable"
+}
+
+#[derive(Copy, Clone, Default)]
+pub struct UseSelf;
+
+impl LintPass for UseSelf {
+    fn get_lints(&self) -> LintArray {
+        lint_array!(USE_SELF)
+    }
+}
+
+impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
+    fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+        if_let_chain!([
+            let ItemImpl(.., ref item_type, ref refs) = item.node,
+            let Ty_::TyPath(QPath::Resolved(_, ref item_path)) = item_type.node,
+        ], {
+            let visitor = &mut UseSelfVisitor {
+                item_path: item_path,
+                cx: cx,
+            };
+            for impl_item_ref in refs {
+                visitor.visit_impl_item(cx.tcx.hir.impl_item(impl_item_ref.id));
+            }
+        })
+    }
+}
+
+struct UseSelfVisitor<'a, 'tcx: 'a> {
+    item_path: &'a Path,
+    cx: &'a LateContext<'a, 'tcx>,
+}
+
+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 should be composed of at least 1 element")
+            .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());
+            });
+        }
+
+        walk_path(self, path);
+    }
+
+    fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+        NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir)
+    }
+}
diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs
index 593cbf6..67319f0 100644
--- a/clippy_lints/src/utils/higher.rs
+++ b/clippy_lints/src/utils/higher.rs
@@ -114,6 +114,13 @@
 
 /// Checks if a `let` decl is from a `for` loop desugaring.
 pub fn is_from_for_desugar(decl: &hir::Decl) -> bool {
+    // This will detect plain for-loops without an actual variable binding:
+    //
+    // ```
+    // for x in some_vec {
+    //   // do stuff
+    // }
+    // ```
     if_let_chain! {[
         let hir::DeclLocal(ref loc) = decl.node,
         let Some(ref expr) = loc.init,
@@ -121,6 +128,22 @@
     ], {
         return true;
     }}
+
+    // This detects a variable binding in for loop to avoid `let_unit_value`
+    // lint (see issue #1964).
+    //
+    // ```
+    // for _ in vec![()] {
+    //   // anything
+    // }
+    // ```
+    if_let_chain! {[
+        let hir::DeclLocal(ref loc) = decl.node,
+        let hir::LocalSource::ForLoopDesugar = loc.source,
+    ], {
+        return true;
+    }}
+
     false
 }
 
@@ -159,7 +182,7 @@
         let hir::ExprPath(ref path) = fun.node,
         is_expn_of(fun.span, "vec").is_some(),
     ], {
-        let fun_def = resolve_node(cx, path, fun.id);
+        let fun_def = resolve_node(cx, path, fun.hir_id);
         return if match_def_path(cx.tcx, fun_def.def_id(), &paths::VEC_FROM_ELEM) && args.len() == 2 {
             // `vec![elem; size]` case
             Some(VecArgs::Repeat(&args[0], &args[1]))
diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs
index ccb2cb7..7b06190 100644
--- a/clippy_lints/src/utils/inspector.rs
+++ b/clippy_lints/src/utils/inspector.rs
@@ -145,7 +145,7 @@
 fn print_decl(cx: &LateContext, decl: &hir::Decl) {
     match decl.node {
         hir::DeclLocal(ref local) => {
-            println!("local variable of type {}", cx.tables.node_id_to_type(local.id));
+            println!("local variable of type {}", cx.tables.node_id_to_type(local.hir_id));
             println!("pattern:");
             print_pat(cx, &local.pat, 0);
             if let Some(ref e) = local.init {
@@ -161,7 +161,7 @@
     let ind = "  ".repeat(indent);
     println!("{}+", ind);
     println!("{}ty: {}", ind, cx.tables.expr_ty(expr));
-    println!("{}adjustments: {:?}", ind, cx.tables.adjustments.get(&expr.id));
+    println!("{}adjustments: {:?}", ind, cx.tables.adjustments().get(expr.hir_id));
     match expr.node {
         hir::ExprBox(ref e) => {
             println!("{}Box", ind);
diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs
index 2e96eeb..12d8f32 100644
--- a/clippy_lints/src/utils/mod.rs
+++ b/clippy_lints/src/utils/mod.rs
@@ -196,7 +196,7 @@
 
 /// Check if the method call given in `expr` belongs to given type.
 pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
-    let method_call = cx.tables.type_dependent_defs[&expr.id];
+    let method_call = cx.tables.type_dependent_defs()[expr.hir_id];
     let trt_id = cx.tcx.impl_of_method(method_call.def_id());
     if let Some(trt_id) = trt_id {
         match_def_path(cx.tcx, trt_id, path)
@@ -207,7 +207,7 @@
 
 /// Check if the method call given in `expr` belongs to given trait.
 pub fn match_trait_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
-    let method_call = cx.tables.type_dependent_defs[&expr.id];
+    let method_call = cx.tables.type_dependent_defs()[expr.hir_id];
     let trt_id = cx.tcx.trait_of_item(method_call.def_id());
     if let Some(trt_id) = trt_id {
         match_def_path(cx.tcx, trt_id, path)
@@ -347,8 +347,8 @@
     })
 }
 
-/// Resolve the definition of a node from its `NodeId`.
-pub fn resolve_node(cx: &LateContext, qpath: &QPath, id: NodeId) -> def::Def {
+/// Resolve the definition of a node from its `HirId`.
+pub fn resolve_node(cx: &LateContext, qpath: &QPath, id: HirId) -> def::Def {
     cx.tables.qpath_def(qpath, id)
 }
 
@@ -656,7 +656,7 @@
 }
 
 pub fn is_adjusted(cx: &LateContext, e: &Expr) -> bool {
-    cx.tables.adjustments.get(&e.id).is_some()
+    cx.tables.adjustments().get(e.hir_id).is_some()
 }
 
 pub struct LimitStack {
@@ -833,9 +833,9 @@
 
 /// Return whether a pattern is refutable.
 pub fn is_refutable(cx: &LateContext, pat: &Pat) -> bool {
-    fn is_enum_variant(cx: &LateContext, qpath: &QPath, did: NodeId) -> bool {
+    fn is_enum_variant(cx: &LateContext, qpath: &QPath, id: HirId) -> bool {
         matches!(
-            cx.tables.qpath_def(qpath, did),
+            cx.tables.qpath_def(qpath, id),
             def::Def::Variant(..) | def::Def::VariantCtor(..)
         )
     }
@@ -851,17 +851,17 @@
         PatKind::Ref(ref pat, _) => is_refutable(cx, pat),
         PatKind::Lit(..) |
         PatKind::Range(..) => true,
-        PatKind::Path(ref qpath) => is_enum_variant(cx, qpath, pat.id),
+        PatKind::Path(ref qpath) => is_enum_variant(cx, qpath, pat.hir_id),
         PatKind::Tuple(ref pats, _) => are_refutable(cx, pats.iter().map(|pat| &**pat)),
         PatKind::Struct(ref qpath, ref fields, _) => {
-            if is_enum_variant(cx, qpath, pat.id) {
+            if is_enum_variant(cx, qpath, pat.hir_id) {
                 true
             } else {
                 are_refutable(cx, fields.iter().map(|field| &*field.node.pat))
             }
         },
         PatKind::TupleStruct(ref qpath, ref pats, _) => {
-            if is_enum_variant(cx, qpath, pat.id) {
+            if is_enum_variant(cx, qpath, pat.hir_id) {
                 true
             } else {
                 are_refutable(cx, pats.iter().map(|pat| &**pat))
diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr
index 1284dd3..4b40fa0 100644
--- a/tests/ui/bit_masks.stderr
+++ b/tests/ui/bit_masks.stderr
@@ -10,7 +10,7 @@
   --> $DIR/bit_masks.rs:12:5
    |
 12 |     x & 0 == 0;
-   |     ^^^^^^^^^^ help: try: `x.trailing_zeros() > 0`
+   |     ^^^^^^^^^^ help: try: `x.trailing_zeros() >= 0`
    |
    = note: `-D verbose-bit-mask` implied by `-D warnings`
 
@@ -18,7 +18,7 @@
   --> $DIR/bit_masks.rs:14:5
    |
 14 |     x & 1 == 0; //ok, compared with zero
-   |     ^^^^^^^^^^ help: try: `x.trailing_zeros() > 1`
+   |     ^^^^^^^^^^ help: try: `x.trailing_zeros() >= 1`
 
 error: incompatible bit mask: `_ & 2` can never be equal to `1`
   --> $DIR/bit_masks.rs:15:5
diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs
index ecae967..d07cf8e 100644
--- a/tests/ui/let_unit.rs
+++ b/tests/ui/let_unit.rs
@@ -18,8 +18,32 @@
         let _a = ();
     }
 
+    consume_units_with_for_loop(); // should be fine as well
+
     let_and_return!(()) // should be fine
 }
 
+// Related to issue #1964
+fn consume_units_with_for_loop() {
+    // `for_let_unit` lint should not be triggered by consuming them using for loop.
+    let v = vec![(), (), ()];
+    let mut count = 0;
+    for _ in v {
+        count += 1;
+    }
+    assert_eq!(count, 3);
+
+    // Same for consuming from some other Iterator<Item = ()>.
+    let (tx, rx) = ::std::sync::mpsc::channel();
+    tx.send(()).unwrap();
+    drop(tx);
+
+    count = 0;
+    for _ in rx.iter() {
+        count += 1;
+    }
+    assert_eq!(count, 1);
+}
+
 #[derive(Copy, Clone)]
 pub struct ContainsUnit(()); // should be fine
diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr
index 5a8de3b..91e4d59 100644
--- a/tests/ui/trailing_zeros.stderr
+++ b/tests/ui/trailing_zeros.stderr
@@ -2,7 +2,7 @@
  --> $DIR/trailing_zeros.rs:7:31
   |
 7 |     let _ = #[clippy(author)] (x & 0b1111 == 0);  // suggest trailing_zeros
-  |                               ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() > 4`
+  |                               ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4`
   |
   = note: `-D verbose-bit-mask` implied by `-D warnings`
 
@@ -10,7 +10,7 @@
  --> $DIR/trailing_zeros.rs:8:13
   |
 8 |     let _ = x & 0b1_1111 == 0; // suggest trailing_zeros
-  |             ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() > 5`
+  |             ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5`
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs
new file mode 100644
index 0000000..40cef1a
--- /dev/null
+++ b/tests/ui/use_self.rs
@@ -0,0 +1,45 @@
+#![feature(plugin)]
+#![plugin(clippy)]
+#![warn(use_self)]
+#![allow(dead_code)]
+
+
+fn main() {}
+
+mod use_self {
+    struct Foo {}
+
+    impl Foo {
+        fn new() -> Foo {
+            Foo {}
+        }
+        fn test() -> Foo {
+            Foo::new()
+        }
+    }
+
+    impl Default for Foo {
+        fn default() -> Foo {
+            Foo::new()
+        }
+    }
+}
+
+mod better {
+    struct Foo {}
+
+    impl Foo {
+        fn new() -> Self {
+            Self {}
+        }
+        fn test() -> Self {
+            Self::new()
+        }
+    }
+
+    impl Default for Foo {
+        fn default() -> Self {
+            Self::new()
+        }
+    }
+}
diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr
new file mode 100644
index 0000000..0cbd574
--- /dev/null
+++ b/tests/ui/use_self.stderr
@@ -0,0 +1,40 @@
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:13:21
+   |
+13 |         fn new() -> Foo {
+   |                     ^^^ help: use the applicable keyword: `Self`
+   |
+   = note: `-D use-self` implied by `-D warnings`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:14:13
+   |
+14 |             Foo {}
+   |             ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:16:22
+   |
+16 |         fn test() -> Foo {
+   |                      ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:17:13
+   |
+17 |             Foo::new()
+   |             ^^^^^^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:22:25
+   |
+22 |         fn default() -> Foo {
+   |                         ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:23:13
+   |
+23 |             Foo::new()
+   |             ^^^^^^^^ help: use the applicable keyword: `Self`
+
+error: aborting due to 6 previous errors
+