]> git.lizzy.rs Git - rust.git/commitdiff
Rustup to rustc 1.16.0-nightly (468227129 2017-01-03): Fix various type errors for...
authorManish Goregaokar <manishsmail@gmail.com>
Tue, 3 Jan 2017 17:19:17 +0000 (09:19 -0800)
committerManish Goregaokar <manishsmail@gmail.com>
Wed, 4 Jan 2017 23:50:18 +0000 (15:50 -0800)
clippy_lints/src/attrs.rs
clippy_lints/src/cyclomatic_complexity.rs
clippy_lints/src/functions.rs
clippy_lints/src/len_zero.rs
clippy_lints/src/lifetimes.rs
clippy_lints/src/methods.rs
clippy_lints/src/missing_doc.rs
clippy_lints/src/ptr.rs
clippy_lints/src/types.rs

index df6ef64a73f80e59416b1cec2f80db6be2b91d61..7fdd8d21205f39e188ac5d2fd330c3ed8d8f8dcb 100644 (file)
@@ -172,8 +172,8 @@ fn is_relevant_impl(cx: &LateContext, item: &ImplItem) -> bool {
 
 fn is_relevant_trait(cx: &LateContext, item: &TraitItem) -> bool {
     match item.node {
-        MethodTraitItem(_, None) => true,
-        MethodTraitItem(_, Some(eid)) => is_relevant_expr(cx, cx.tcx.map.expr(eid)),
+        TraitItemKind::Method(_, None) => true,
+        TraitItemKind::Method(_, Some(eid)) => is_relevant_expr(cx, cx.tcx.map.expr(eid)),
         _ => false,
     }
 }
index 897a578f19a7ca72b551aa9780a0990a9b4f8ac8..34cd40a8fdf15da82d5ffac43032cddeb754c9f5 100644 (file)
@@ -106,7 +106,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem)
     }
 
     fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
-        if let MethodTraitItem(_, Some(eid)) = item.node {
+        if let TraitItemKind::Method(_, Some(eid)) = item.node {
             self.check(cx, cx.tcx.map.expr(eid), item.span);
         }
     }
index 5ad676e57a088644b4f938256666c00e7e346b99..eb666dcc5109df5c1f49dafebf56bb4b95e9618e 100644 (file)
@@ -106,7 +106,7 @@ fn check_fn(
     }
 
     fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
-        if let hir::MethodTraitItem(ref sig, eid) = item.node {
+        if let hir::TraitItemKind::Method(ref sig, eid) = item.node {
             // don't lint extern functions decls, it's not their fault
             if sig.abi == Abi::Rust {
                 self.check_arg_number(cx, &sig.decl, item.span);
index 22835b4884033e1e79d2a419f0e693d425ff3b66..ff19a59b5abea8db80ca15ee6e3ac2e1805cbc34 100644 (file)
@@ -90,7 +90,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
 fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItem]) {
     fn is_named_self(item: &TraitItem, name: &str) -> bool {
         &*item.name.as_str() == name &&
-        if let MethodTraitItem(ref sig, _) = item.node {
+        if let TraitItemKind::Method(ref sig, _) = item.node {
             if sig.decl.has_self() {
                 sig.decl.inputs.len() == 1
             } else {
index fa0afd90d332140e2efa77027b57dc5df6f29fce..2a258ff5db77ade56507ee8405fbf5cea4ac4c3f 100644 (file)
@@ -70,7 +70,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem)
     }
 
     fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
-        if let MethodTraitItem(ref sig, _) = item.node {
+        if let TraitItemKind::Method(ref sig, _) = item.node {
             check_fn_inner(cx, &sig.decl, &sig.generics, item.span);
         }
     }
index 591b395fe7099d247b68bd427ea8eeeca372f0fb..6d9860d92fdf53fe727a83ecf0f035c16326f3e6 100644 (file)
@@ -1,7 +1,6 @@
 use rustc::hir;
 use rustc::lint::*;
 use rustc::middle::const_val::ConstVal;
-use rustc::middle::const_qualif::ConstQualif;
 use rustc::ty;
 use rustc::hir::def::Def;
 use rustc_const_eval::EvalHint::ExprTypeChecked;
@@ -638,7 +637,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::I
         let item = cx.tcx.map.expect_item(parent);
         if_let_chain! {[
             let hir::ImplItemKind::Method(ref sig, _) = implitem.node,
-            let Some(explicit_self) = sig.decl.inputs.get(0).and_then(hir::Arg::to_self),
+            let Some(first_arg) = sig.decl.inputs.get(0),
             let hir::ItemImpl(_, _, _, None, _, _) = item.node,
         ], {
             // check missing trait implementations
@@ -646,7 +645,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::I
                 if &*name.as_str() == method_name &&
                    sig.decl.inputs.len() == n_args &&
                    out_type.matches(&sig.decl.output) &&
-                   self_kind.matches(&explicit_self, false) {
+                   self_kind.matches(&first_arg, false) {
                     span_lint(cx, SHOULD_IMPLEMENT_TRAIT, implitem.span, &format!(
                         "defining a method called `{}` on this type; consider implementing \
                          the `{}` trait or choosing a less ambiguous name", name, trait_name));
@@ -752,11 +751,12 @@ fn check_general_case(
     ) {
         // don't lint for constant values
         // FIXME: can we `expect` here instead of match?
-        if let Some(qualif) = cx.tcx.const_qualif_map.borrow().get(&arg.id) {
-            if !qualif.contains(ConstQualif::NOT_CONST) {
-                return;
-            }
+        let promotable = cx.tcx().rvalue_promotable_to_static.borrow()
+                             .get(&arg.id).cloned().unwrap_or(true);
+        if !promotable {
+            return;
         }
+
         // (path, fn_has_argument, methods, suffix)
         let know_types: &[(&[_], _, &[_], _)] =
             &[(&paths::BTREEMAP_ENTRY, false, &["or_insert"], "with"),
@@ -1347,7 +1347,10 @@ enum SelfKind {
 }
 
 impl SelfKind {
-    fn matches(self, slf: &hir::ExplicitSelf, allow_value_for_ref: bool) -> bool {
+    fn matches(self, slf: &hir::Arg, allow_value_for_ref: bool) -> bool {
+        if !slf.has_self() {
+            return self == No;
+        }
         match (self, &slf.node) {
             (SelfKind::Value, &hir::SelfKind::Value(_)) |
             (SelfKind::Ref, &hir::SelfKind::Region(_, hir::Mutability::MutImmutable)) |
index 70696ea3908beb1dae77522446eaeeb8d03aa558..d5be44e8c2b93ec01dc3b9a8e06bc2ede9f330d7 100644 (file)
@@ -136,9 +136,9 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
 
     fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem) {
         let desc = match trait_item.node {
-            hir::ConstTraitItem(..) => "an associated constant",
-            hir::MethodTraitItem(..) => "a trait method",
-            hir::TypeTraitItem(..) => "an associated type",
+            hir::TraitItemKind::Const(..) => "an associated constant",
+            hir::TraitItemKind::Method(..) => "a trait method",
+            hir::TraitItemKind::Type(..) => "an associated type",
         };
 
         self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, desc);
index 2f74390cc73e272bdfd44c5e4c48cdae18d169d5..0b7bf3c3096365f75a4c3221702040b3ca060c4a 100644 (file)
@@ -73,7 +73,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem)
     }
 
     fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
-        if let MethodTraitItem(ref sig, _) = item.node {
+        if let TraitItemKind::Method(ref sig, _) = item.node {
             check_fn(cx, &sig.decl, item.id);
         }
     }
index 9912c52492a5e955913459a178f5276f3e537470..327e638d9b849b14581fc8ceabae818ab6d08549 100644 (file)
@@ -87,9 +87,9 @@ fn check_struct_field(&mut self, cx: &LateContext, field: &StructField) {
 
     fn check_trait_item(&mut self, cx: &LateContext, item: &TraitItem) {
         match item.node {
-            ConstTraitItem(ref ty, _) |
-            TypeTraitItem(_, Some(ref ty)) => check_ty(cx, ty),
-            MethodTraitItem(ref sig, _) => check_fn_decl(cx, &sig.decl),
+            TraitItemKind::Const(ref ty, _) |
+            TraitItemKind::Type(_, Some(ref ty)) => check_ty(cx, ty),
+            TraitItemKind::Method(ref sig, _) => check_fn_decl(cx, &sig.decl),
             _ => (),
         }
     }
@@ -624,9 +624,9 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
 
     fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
         match item.node {
-            ConstTraitItem(ref ty, _) |
-            TypeTraitItem(_, Some(ref ty)) => self.check_type(cx, ty),
-            MethodTraitItem(MethodSig { ref decl, .. }, None) => self.check_fndecl(cx, decl),
+            TraitItemKind::Const(ref ty, _) |
+            TraitItemKind::Type(_, Some(ref ty)) => self.check_type(cx, ty),
+            TraitItemKind::Method(MethodSig { ref decl, .. }, None) => self.check_fndecl(cx, decl),
             // methods with default impl are covered by check_fn
             _ => (),
         }