]> git.lizzy.rs Git - rust.git/commitdiff
Rustup to *1.10.0-nightly (22ac88f1a 2016-05-11)*
authormcarton <cartonmartin+git@gmail.com>
Thu, 12 May 2016 17:11:13 +0000 (19:11 +0200)
committermcarton <cartonmartin+git@gmail.com>
Thu, 12 May 2016 19:22:38 +0000 (21:22 +0200)
src/attrs.rs
src/cyclomatic_complexity.rs
src/derive.rs
src/escape.rs
src/methods.rs
src/panic.rs
src/types.rs
src/utils/mod.rs
src/utils/paths.rs

index ca7813d3860816eaedbbbc9f94c161e1211b32d1..0cf62633de4e070274f367de195c8e383f9cc118 100644 (file)
@@ -130,7 +130,7 @@ fn is_relevant_expr(expr: &Expr) -> bool {
         ExprRet(None) | ExprBreak(_) => false,
         ExprCall(ref path_expr, _) => {
             if let ExprPath(_, ref path) = path_expr.node {
-                !match_path(path, &paths::BEGIN_UNWIND)
+                !match_path(path, &paths::BEGIN_PANIC)
             } else {
                 true
             }
index 858affd2bbb1bf891d0c163a0d0fa15556dccb2b..8ae0d2c97c50f5eb5d2b1fcf689bf503a41183e1 100644 (file)
@@ -58,7 +58,7 @@ fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, block: &Block, span
             divergence: 0,
             short_circuits: 0,
             returns: 0,
-            tcx: cx.tcx,
+            tcx: &cx.tcx,
         };
         helper.visit_block(block);
         let CCHelper { match_arms, divergence, short_circuits, returns, .. } = helper;
@@ -117,15 +117,15 @@ fn exit_lint_attrs(&mut self, cx: &LateContext, attrs: &[Attribute]) {
     }
 }
 
-struct CCHelper<'a, 'tcx: 'a> {
+struct CCHelper<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
     match_arms: u64,
     divergence: u64,
     returns: u64,
     short_circuits: u64, // && and ||
-    tcx: &'a ty::TyCtxt<'tcx>,
+    tcx: &'a ty::TyCtxt<'a, 'gcx, 'tcx>,
 }
 
-impl<'a, 'b, 'tcx> Visitor<'a> for CCHelper<'b, 'tcx> {
+impl<'a, 'b, 'tcx, 'gcx> Visitor<'a> for CCHelper<'b, 'gcx, 'tcx> {
     fn visit_expr(&mut self, e: &'a Expr) {
         match e.node {
             ExprMatch(_, ref arms, _) => {
index c9ac8f0a948b99b1f917dad2d6e4f907bcb59c32..f08522953aa641599dd697e74dfb0d9716e7fae2 100644 (file)
@@ -86,7 +86,7 @@ fn check_item(&mut self, cx: &LateContext, item: &Item) {
 }
 
 /// Implementation of the `DERIVE_HASH_XOR_EQ` lint.
-fn check_hash_peq<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &TraitRef, ty: ty::Ty<'tcx>, hash_is_automatically_derived: bool) {
+fn check_hash_peq<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &TraitRef, ty: ty::Ty<'tcx>, hash_is_automatically_derived: bool) {
     if_let_chain! {[
         match_path(&trait_ref.path, &paths::HASH),
         let Some(peq_trait_def_id) = cx.tcx.lang_items.eq_trait()
@@ -94,7 +94,7 @@ fn check_hash_peq<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &
         let peq_trait_def = cx.tcx.lookup_trait_def(peq_trait_def_id);
 
         // Look for the PartialEq implementations for `ty`
-        peq_trait_def.for_each_relevant_impl(&cx.tcx, ty, |impl_id| {
+        peq_trait_def.for_each_relevant_impl(cx.tcx, ty, |impl_id| {
             let peq_is_automatically_derived = cx.tcx.get_attrs(impl_id).iter().any(is_automatically_derived);
 
             if peq_is_automatically_derived == hash_is_automatically_derived {
@@ -131,9 +131,9 @@ fn check_hash_peq<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &
 fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref: &TraitRef, ty: ty::Ty<'tcx>) {
     if match_path(&trait_ref.path, &paths::CLONE_TRAIT) {
         let parameter_environment = ty::ParameterEnvironment::for_item(cx.tcx, item.id);
-        let subst_ty = ty.subst(cx.tcx, &parameter_environment.free_substs);
+        let subst_ty = ty.subst(cx.tcx, parameter_environment.free_substs);
 
-        if subst_ty.moves_by_default(&parameter_environment, item.span) {
+        if subst_ty.moves_by_default(cx.tcx.global_tcx(), &parameter_environment, item.span) {
             return; // ty is not Copy
         }
 
index ff841b18066818d288605eb48132fca525c3bf0a..b5172269a1e96bc806bf789967550d9092b046fd 100644 (file)
@@ -1,11 +1,9 @@
 use rustc::hir::*;
 use rustc::hir::intravisit as visit;
 use rustc::hir::map::Node::{NodeExpr, NodeStmt};
-use rustc::infer;
 use rustc::lint::*;
 use rustc::middle::expr_use_visitor::*;
 use rustc::middle::mem_categorization::{cmt, Categorization};
-use rustc::traits::ProjectionMode;
 use rustc::ty::adjustment::AutoAdjustment;
 use rustc::ty;
 use rustc::util::nodemap::NodeSet;
@@ -42,7 +40,7 @@ fn is_non_trait_box(ty: ty::Ty) -> bool {
 }
 
 struct EscapeDelegate<'a, 'tcx: 'a> {
-    cx: &'a LateContext<'a, 'tcx>,
+    tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
     set: NodeSet,
 }
 
@@ -55,15 +53,18 @@ fn get_lints(&self) -> LintArray {
 impl LateLintPass for EscapePass {
     fn check_fn(&mut self, cx: &LateContext, _: visit::FnKind, decl: &FnDecl, body: &Block, _: Span, id: NodeId) {
         let param_env = ty::ParameterEnvironment::for_item(cx.tcx, id);
-        let infcx = infer::new_infer_ctxt(cx.tcx, &cx.tcx.tables, Some(param_env), ProjectionMode::Any);
+
+        let infcx = cx.tcx.borrowck_fake_infer_ctxt(param_env);
         let mut v = EscapeDelegate {
-            cx: cx,
+            tcx: cx.tcx,
             set: NodeSet(),
         };
+
         {
             let mut vis = ExprUseVisitor::new(&mut v, &infcx);
             vis.walk_fn(decl, body);
         }
+
         for node in v.set {
             span_lint(cx,
                       BOXED_LOCAL,
@@ -75,7 +76,6 @@ fn check_fn(&mut self, cx: &LateContext, _: visit::FnKind, decl: &FnDecl, body:
 
 impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
     fn consume(&mut self, _: NodeId, _: Span, cmt: cmt<'tcx>, mode: ConsumeMode) {
-
         if let Categorization::Local(lid) = cmt.cat {
             if self.set.contains(&lid) {
                 if let Move(DirectRefMove) = mode {
@@ -87,7 +87,7 @@ fn consume(&mut self, _: NodeId, _: Span, cmt: cmt<'tcx>, mode: ConsumeMode) {
     }
     fn matched_pat(&mut self, _: &Pat, _: cmt<'tcx>, _: MatchMode) {}
     fn consume_pat(&mut self, consume_pat: &Pat, cmt: cmt<'tcx>, _: ConsumeMode) {
-        let map = &self.cx.tcx.map;
+        let map = &self.tcx.map;
         if map.is_argument(consume_pat.id) {
             // Skip closure arguments
             if let Some(NodeExpr(..)) = map.find(map.get_parent_node(consume_pat.id)) {
@@ -132,8 +132,7 @@ fn borrow(&mut self, borrow_id: NodeId, _: Span, cmt: cmt<'tcx>, _: ty::Region,
 
         if let Categorization::Local(lid) = cmt.cat {
             if self.set.contains(&lid) {
-                if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.cx
-                                                                        .tcx
+                if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.tcx
                                                                         .tables
                                                                         .borrow()
                                                                         .adjustments
@@ -148,13 +147,11 @@ fn borrow(&mut self, borrow_id: NodeId, _: Span, cmt: cmt<'tcx>, _: ty::Region,
                     }
                 } else if LoanCause::AddrOf == loan_cause {
                     // &x
-                    if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.cx
-                                                                            .tcx
+                    if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.tcx
                                                                             .tables
                                                                             .borrow()
                                                                             .adjustments
-                                                                            .get(&self.cx
-                                                                                      .tcx
+                                                                            .get(&self.tcx
                                                                                       .map
                                                                                       .get_parent_node(borrow_id)) {
                         if adj.autoderefs <= 1 {
index b47ae924bf012440a34fcf0e0fca0a5b2a2fa5ae..c4ea1868d33d0ee5fd2c0384bd90d2226bf6969f 100644 (file)
@@ -560,7 +560,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &Expr) {
     let parent = cx.tcx.map.get_parent(expr.id);
     let parameter_environment = ty::ParameterEnvironment::for_item(cx.tcx, parent);
 
-    if !ty.moves_by_default(&parameter_environment, expr.span) {
+    if !ty.moves_by_default(cx.tcx.global_tcx(), &parameter_environment, expr.span) {
         span_lint(cx, CLONE_ON_COPY, expr.span, "using `clone` on a `Copy` type");
     }
 }
@@ -1044,5 +1044,5 @@ fn is_bool(ty: &Ty) -> bool {
 
 fn is_copy<'a, 'ctx>(cx: &LateContext<'a, 'ctx>, ty: ty::Ty<'ctx>, item: &Item) -> bool {
     let env = ty::ParameterEnvironment::for_item(cx.tcx, item.id);
-    !ty.subst(cx.tcx, &env.free_substs).moves_by_default(&env, item.span)
+    !ty.subst(cx.tcx, env.free_substs).moves_by_default(cx.tcx.global_tcx(), &env, item.span)
 }
index 78499fa1a1aa7bdc77d2992032897d87b31801be..d744d2a6308ae13812bff8d45cd0832ac9cdd5b4 100644 (file)
@@ -33,7 +33,7 @@ fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
             let ExprCall(ref fun, ref params) = ex.node,
             params.len() == 2,
             let ExprPath(None, ref path) = fun.node,
-            match_path(path, &paths::BEGIN_UNWIND),
+            match_path(path, &paths::BEGIN_PANIC),
             let ExprLit(ref lit) = params[0].node,
             is_direct_expn_of(cx, params[0].span, "panic").is_some(),
             let LitKind::Str(ref string, _) = lit.node,
index f63538e974d005815e185d8b97e2463e79c717f7..0a0c7252eb7696bf1285f16fa7f82e059638c95f 100644 (file)
@@ -105,7 +105,7 @@ fn check_ty(&mut self, cx: &LateContext, ast_ty: &Ty) {
 fn check_let_unit(cx: &LateContext, decl: &Decl) {
     if let DeclLocal(ref local) = decl.node {
         let bindtype = &cx.tcx.pat_ty(&local.pat).sty;
-        if *bindtype == ty::TyTuple(vec![]) {
+        if *bindtype == ty::TyTuple(&[]) {
             if in_external_macro(cx, decl.span) || in_macro(cx, local.pat.span) {
                 return;
             }
@@ -162,7 +162,7 @@ fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
         if let ExprBinary(ref cmp, ref left, _) = expr.node {
             let op = cmp.node;
             let sty = &cx.tcx.expr_ty(left).sty;
-            if *sty == ty::TyTuple(vec![]) && op.is_comparison() {
+            if *sty == ty::TyTuple(&[]) && op.is_comparison() {
                 let result = match op {
                     BiEq | BiLe | BiGe => "true",
                     _ => "false",
index 3e77ffb2c24c8cf0be23887dc51afc74e1bc055c..10bfe56e925e3218b47ebcf07a45da8a9b534393 100644 (file)
@@ -2,7 +2,6 @@
 use rustc::hir::*;
 use rustc::hir::def_id::DefId;
 use rustc::hir::map::Node;
-use rustc::infer;
 use rustc::lint::{LintContext, LateContext, Level, Lint};
 use rustc::middle::cstore;
 use rustc::session::Session;
@@ -274,15 +273,15 @@ pub fn implements_trait<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>,
     cx.tcx.populate_implementations_for_trait_if_necessary(trait_id);
 
     let ty = cx.tcx.erase_regions(&ty);
-    let infcx = infer::new_infer_ctxt(cx.tcx, &cx.tcx.tables, None, ProjectionMode::Any);
-    let obligation = traits::predicate_for_trait_def(cx.tcx,
-                                                     traits::ObligationCause::dummy(),
-                                                     trait_id,
-                                                     0,
-                                                     ty,
-                                                     ty_params);
-
-    traits::SelectionContext::new(&infcx).evaluate_obligation_conservatively(&obligation)
+    cx.tcx.infer_ctxt(None, None, ProjectionMode::Any).enter(|infcx| {
+        let obligation = cx.tcx.predicate_for_trait_def(traits::ObligationCause::dummy(),
+                                                        trait_id,
+                                                        0,
+                                                        ty,
+                                                        ty_params);
+
+        traits::SelectionContext::new(&infcx).evaluate_obligation_conservatively(&obligation)
+    })
 }
 
 /// Match an `Expr` against a chain of methods, and return the matched `Expr`s.
@@ -795,7 +794,7 @@ fn get_field<'a>(name: &str, fields: &'a [Field]) -> Option<&'a Expr> {
 /// Convenience function to get the return type of a function or `None` if the function diverges.
 pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Option<ty::Ty<'tcx>> {
     let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, fn_item);
-    let fn_sig = cx.tcx.node_id_to_type(fn_item).fn_sig().subst(cx.tcx, &parameter_env.free_substs);
+    let fn_sig = cx.tcx.node_id_to_type(fn_item).fn_sig().subst(cx.tcx, parameter_env.free_substs);
     let fn_sig = cx.tcx.liberate_late_bound_regions(parameter_env.free_id_outlive, &fn_sig);
     if let ty::FnConverging(ret_ty) = fn_sig.output {
         Some(ret_ty)
@@ -809,10 +808,11 @@ pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Optio
 // not for type parameters.
 pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: ty::Ty<'tcx>, b: ty::Ty<'tcx>, parameter_item: NodeId) -> bool {
     let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, parameter_item);
-    let infcx = infer::new_infer_ctxt(cx.tcx, &cx.tcx.tables, Some(parameter_env), ProjectionMode::Any);
-    let new_a = a.subst(infcx.tcx, &infcx.parameter_environment.free_substs);
-    let new_b = b.subst(infcx.tcx, &infcx.parameter_environment.free_substs);
-    infcx.can_equate(&new_a, &new_b).is_ok()
+    cx.tcx.infer_ctxt(None, Some(parameter_env), ProjectionMode::Any).enter(|infcx| {
+        let new_a = a.subst(infcx.tcx, infcx.parameter_environment.free_substs);
+        let new_b = b.subst(infcx.tcx, infcx.parameter_environment.free_substs);
+        infcx.can_equate(&new_a, &new_b).is_ok()
+    })
 }
 
 /// Recover the essential nodes of a desugared for loop:
index 2e6ceb5009697ee3e394a3bf329522237f771b3d..3db1e1c557293bc543eb875805180952740f70bf 100644 (file)
@@ -1,6 +1,6 @@
 //! This module contains paths to types and functions Clippy needs to know about.
 
-pub const BEGIN_UNWIND: [&'static str; 3] = ["std", "rt", "begin_unwind"];
+pub const BEGIN_PANIC: [&'static str; 3] = ["std", "rt", "begin_panic"];
 pub const BINARY_HEAP: [&'static str; 3] = ["collections", "binary_heap", "BinaryHeap"];
 pub const BOX: [&'static str; 3] = ["std", "boxed", "Box"];
 pub const BOX_NEW: [&'static str; 4] = ["std", "boxed", "Box", "new"];