Skip to content

Commit 7d4042b

Browse files
committed
Merge pull request #922 from Manishearth/rustup
Rustup to *1.10.0-nightly (22ac88f 2016-05-11)*
2 parents fe6ad91 + 392df9f commit 7d4042b

11 files changed

+48
-44
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 0.0.67 — 2016-05-12
5+
* Rustup to *rustc 1.10.0-nightly (22ac88f1a 2016-05-11)*
6+
7+
## 0.0.66 — 2016-05-11
8+
* New `cargo clippy` subcommand
9+
* New lints: [`assign_op_pattern`], [`assign_ops`], [`needless_borrow`]
10+
411
## 0.0.65 — 2016-05-08
512
* Rustup to *rustc 1.10.0-nightly (62e2b2fb7 2016-05-06)*
613
* New lints: [`float_arithmetic`], [`integer_arithmetic`]

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.66"
3+
version = "0.0.67"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",

src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn is_relevant_expr(expr: &Expr) -> bool {
130130
ExprRet(None) | ExprBreak(_) => false,
131131
ExprCall(ref path_expr, _) => {
132132
if let ExprPath(_, ref path) = path_expr.node {
133-
!match_path(path, &paths::BEGIN_UNWIND)
133+
!match_path(path, &paths::BEGIN_PANIC)
134134
} else {
135135
true
136136
}

src/cyclomatic_complexity.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl CyclomaticComplexity {
5858
divergence: 0,
5959
short_circuits: 0,
6060
returns: 0,
61-
tcx: cx.tcx,
61+
tcx: &cx.tcx,
6262
};
6363
helper.visit_block(block);
6464
let CCHelper { match_arms, divergence, short_circuits, returns, .. } = helper;
@@ -117,15 +117,15 @@ impl LateLintPass for CyclomaticComplexity {
117117
}
118118
}
119119

120-
struct CCHelper<'a, 'tcx: 'a> {
120+
struct CCHelper<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
121121
match_arms: u64,
122122
divergence: u64,
123123
returns: u64,
124124
short_circuits: u64, // && and ||
125-
tcx: &'a ty::TyCtxt<'tcx>,
125+
tcx: &'a ty::TyCtxt<'a, 'gcx, 'tcx>,
126126
}
127127

128-
impl<'a, 'b, 'tcx> Visitor<'a> for CCHelper<'b, 'tcx> {
128+
impl<'a, 'b, 'tcx, 'gcx> Visitor<'a> for CCHelper<'b, 'gcx, 'tcx> {
129129
fn visit_expr(&mut self, e: &'a Expr) {
130130
match e.node {
131131
ExprMatch(_, ref arms, _) => {

src/derive.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ impl LateLintPass for Derive {
8686
}
8787

8888
/// Implementation of the `DERIVE_HASH_XOR_EQ` lint.
89-
fn check_hash_peq<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &TraitRef, ty: ty::Ty<'tcx>, hash_is_automatically_derived: bool) {
89+
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) {
9090
if_let_chain! {[
9191
match_path(&trait_ref.path, &paths::HASH),
9292
let Some(peq_trait_def_id) = cx.tcx.lang_items.eq_trait()
9393
], {
9494
let peq_trait_def = cx.tcx.lookup_trait_def(peq_trait_def_id);
9595

9696
// Look for the PartialEq implementations for `ty`
97-
peq_trait_def.for_each_relevant_impl(&cx.tcx, ty, |impl_id| {
97+
peq_trait_def.for_each_relevant_impl(cx.tcx, ty, |impl_id| {
9898
let peq_is_automatically_derived = cx.tcx.get_attrs(impl_id).iter().any(is_automatically_derived);
9999

100100
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: &
131131
fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref: &TraitRef, ty: ty::Ty<'tcx>) {
132132
if match_path(&trait_ref.path, &paths::CLONE_TRAIT) {
133133
let parameter_environment = ty::ParameterEnvironment::for_item(cx.tcx, item.id);
134-
let subst_ty = ty.subst(cx.tcx, &parameter_environment.free_substs);
134+
let subst_ty = ty.subst(cx.tcx, parameter_environment.free_substs);
135135

136-
if subst_ty.moves_by_default(&parameter_environment, item.span) {
136+
if subst_ty.moves_by_default(cx.tcx.global_tcx(), &parameter_environment, item.span) {
137137
return; // ty is not Copy
138138
}
139139

src/escape.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use rustc::hir::*;
22
use rustc::hir::intravisit as visit;
33
use rustc::hir::map::Node::{NodeExpr, NodeStmt};
4-
use rustc::infer;
54
use rustc::lint::*;
65
use rustc::middle::expr_use_visitor::*;
76
use rustc::middle::mem_categorization::{cmt, Categorization};
8-
use rustc::traits::ProjectionMode;
97
use rustc::ty::adjustment::AutoAdjustment;
108
use rustc::ty;
119
use rustc::util::nodemap::NodeSet;
@@ -42,7 +40,7 @@ fn is_non_trait_box(ty: ty::Ty) -> bool {
4240
}
4341

4442
struct EscapeDelegate<'a, 'tcx: 'a> {
45-
cx: &'a LateContext<'a, 'tcx>,
43+
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
4644
set: NodeSet,
4745
}
4846

@@ -55,15 +53,18 @@ impl LintPass for EscapePass {
5553
impl LateLintPass for EscapePass {
5654
fn check_fn(&mut self, cx: &LateContext, _: visit::FnKind, decl: &FnDecl, body: &Block, _: Span, id: NodeId) {
5755
let param_env = ty::ParameterEnvironment::for_item(cx.tcx, id);
58-
let infcx = infer::new_infer_ctxt(cx.tcx, &cx.tcx.tables, Some(param_env), ProjectionMode::Any);
56+
57+
let infcx = cx.tcx.borrowck_fake_infer_ctxt(param_env);
5958
let mut v = EscapeDelegate {
60-
cx: cx,
59+
tcx: cx.tcx,
6160
set: NodeSet(),
6261
};
62+
6363
{
6464
let mut vis = ExprUseVisitor::new(&mut v, &infcx);
6565
vis.walk_fn(decl, body);
6666
}
67+
6768
for node in v.set {
6869
span_lint(cx,
6970
BOXED_LOCAL,
@@ -75,7 +76,6 @@ impl LateLintPass for EscapePass {
7576

7677
impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
7778
fn consume(&mut self, _: NodeId, _: Span, cmt: cmt<'tcx>, mode: ConsumeMode) {
78-
7979
if let Categorization::Local(lid) = cmt.cat {
8080
if self.set.contains(&lid) {
8181
if let Move(DirectRefMove) = mode {
@@ -87,7 +87,7 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
8787
}
8888
fn matched_pat(&mut self, _: &Pat, _: cmt<'tcx>, _: MatchMode) {}
8989
fn consume_pat(&mut self, consume_pat: &Pat, cmt: cmt<'tcx>, _: ConsumeMode) {
90-
let map = &self.cx.tcx.map;
90+
let map = &self.tcx.map;
9191
if map.is_argument(consume_pat.id) {
9292
// Skip closure arguments
9393
if let Some(NodeExpr(..)) = map.find(map.get_parent_node(consume_pat.id)) {
@@ -132,8 +132,7 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
132132

133133
if let Categorization::Local(lid) = cmt.cat {
134134
if self.set.contains(&lid) {
135-
if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.cx
136-
.tcx
135+
if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.tcx
137136
.tables
138137
.borrow()
139138
.adjustments
@@ -148,13 +147,11 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
148147
}
149148
} else if LoanCause::AddrOf == loan_cause {
150149
// &x
151-
if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.cx
152-
.tcx
150+
if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.tcx
153151
.tables
154152
.borrow()
155153
.adjustments
156-
.get(&self.cx
157-
.tcx
154+
.get(&self.tcx
158155
.map
159156
.get_parent_node(borrow_id)) {
160157
if adj.autoderefs <= 1 {

src/methods.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &Expr) {
560560
let parent = cx.tcx.map.get_parent(expr.id);
561561
let parameter_environment = ty::ParameterEnvironment::for_item(cx.tcx, parent);
562562

563-
if !ty.moves_by_default(&parameter_environment, expr.span) {
563+
if !ty.moves_by_default(cx.tcx.global_tcx(), &parameter_environment, expr.span) {
564564
span_lint(cx, CLONE_ON_COPY, expr.span, "using `clone` on a `Copy` type");
565565
}
566566
}
@@ -1044,5 +1044,5 @@ fn is_bool(ty: &Ty) -> bool {
10441044

10451045
fn is_copy<'a, 'ctx>(cx: &LateContext<'a, 'ctx>, ty: ty::Ty<'ctx>, item: &Item) -> bool {
10461046
let env = ty::ParameterEnvironment::for_item(cx.tcx, item.id);
1047-
!ty.subst(cx.tcx, &env.free_substs).moves_by_default(&env, item.span)
1047+
!ty.subst(cx.tcx, env.free_substs).moves_by_default(cx.tcx.global_tcx(), &env, item.span)
10481048
}

src/panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl LateLintPass for PanicPass {
3333
let ExprCall(ref fun, ref params) = ex.node,
3434
params.len() == 2,
3535
let ExprPath(None, ref path) = fun.node,
36-
match_path(path, &paths::BEGIN_UNWIND),
36+
match_path(path, &paths::BEGIN_PANIC),
3737
let ExprLit(ref lit) = params[0].node,
3838
is_direct_expn_of(cx, params[0].span, "panic").is_some(),
3939
let LitKind::Str(ref string, _) = lit.node,

src/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ declare_lint! {
105105
fn check_let_unit(cx: &LateContext, decl: &Decl) {
106106
if let DeclLocal(ref local) = decl.node {
107107
let bindtype = &cx.tcx.pat_ty(&local.pat).sty;
108-
if *bindtype == ty::TyTuple(vec![]) {
108+
if *bindtype == ty::TyTuple(&[]) {
109109
if in_external_macro(cx, decl.span) || in_macro(cx, local.pat.span) {
110110
return;
111111
}
@@ -162,7 +162,7 @@ impl LateLintPass for UnitCmp {
162162
if let ExprBinary(ref cmp, ref left, _) = expr.node {
163163
let op = cmp.node;
164164
let sty = &cx.tcx.expr_ty(left).sty;
165-
if *sty == ty::TyTuple(vec![]) && op.is_comparison() {
165+
if *sty == ty::TyTuple(&[]) && op.is_comparison() {
166166
let result = match op {
167167
BiEq | BiLe | BiGe => "true",
168168
_ => "false",

src/utils/mod.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use reexport::*;
22
use rustc::hir::*;
33
use rustc::hir::def_id::DefId;
44
use rustc::hir::map::Node;
5-
use rustc::infer;
65
use rustc::lint::{LintContext, LateContext, Level, Lint};
76
use rustc::middle::cstore;
87
use rustc::session::Session;
@@ -274,15 +273,15 @@ pub fn implements_trait<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>,
274273
cx.tcx.populate_implementations_for_trait_if_necessary(trait_id);
275274

276275
let ty = cx.tcx.erase_regions(&ty);
277-
let infcx = infer::new_infer_ctxt(cx.tcx, &cx.tcx.tables, None, ProjectionMode::Any);
278-
let obligation = traits::predicate_for_trait_def(cx.tcx,
279-
traits::ObligationCause::dummy(),
280-
trait_id,
281-
0,
282-
ty,
283-
ty_params);
284-
285-
traits::SelectionContext::new(&infcx).evaluate_obligation_conservatively(&obligation)
276+
cx.tcx.infer_ctxt(None, None, ProjectionMode::Any).enter(|infcx| {
277+
let obligation = cx.tcx.predicate_for_trait_def(traits::ObligationCause::dummy(),
278+
trait_id,
279+
0,
280+
ty,
281+
ty_params);
282+
283+
traits::SelectionContext::new(&infcx).evaluate_obligation_conservatively(&obligation)
284+
})
286285
}
287286

288287
/// Match an `Expr` against a chain of methods, and return the matched `Expr`s.
@@ -795,7 +794,7 @@ pub fn unsugar_range(expr: &Expr) -> Option<UnsugaredRange> {
795794
/// Convenience function to get the return type of a function or `None` if the function diverges.
796795
pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Option<ty::Ty<'tcx>> {
797796
let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, fn_item);
798-
let fn_sig = cx.tcx.node_id_to_type(fn_item).fn_sig().subst(cx.tcx, &parameter_env.free_substs);
797+
let fn_sig = cx.tcx.node_id_to_type(fn_item).fn_sig().subst(cx.tcx, parameter_env.free_substs);
799798
let fn_sig = cx.tcx.liberate_late_bound_regions(parameter_env.free_id_outlive, &fn_sig);
800799
if let ty::FnConverging(ret_ty) = fn_sig.output {
801800
Some(ret_ty)
@@ -809,10 +808,11 @@ pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Optio
809808
// not for type parameters.
810809
pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: ty::Ty<'tcx>, b: ty::Ty<'tcx>, parameter_item: NodeId) -> bool {
811810
let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, parameter_item);
812-
let infcx = infer::new_infer_ctxt(cx.tcx, &cx.tcx.tables, Some(parameter_env), ProjectionMode::Any);
813-
let new_a = a.subst(infcx.tcx, &infcx.parameter_environment.free_substs);
814-
let new_b = b.subst(infcx.tcx, &infcx.parameter_environment.free_substs);
815-
infcx.can_equate(&new_a, &new_b).is_ok()
811+
cx.tcx.infer_ctxt(None, Some(parameter_env), ProjectionMode::Any).enter(|infcx| {
812+
let new_a = a.subst(infcx.tcx, infcx.parameter_environment.free_substs);
813+
let new_b = b.subst(infcx.tcx, infcx.parameter_environment.free_substs);
814+
infcx.can_equate(&new_a, &new_b).is_ok()
815+
})
816816
}
817817

818818
/// Recover the essential nodes of a desugared for loop:

src/utils/paths.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! This module contains paths to types and functions Clippy needs to know about.
22
3-
pub const BEGIN_UNWIND: [&'static str; 3] = ["std", "rt", "begin_unwind"];
3+
pub const BEGIN_PANIC: [&'static str; 3] = ["std", "rt", "begin_panic"];
44
pub const BINARY_HEAP: [&'static str; 3] = ["collections", "binary_heap", "BinaryHeap"];
55
pub const BOX: [&'static str; 3] = ["std", "boxed", "Box"];
66
pub const BOX_NEW: [&'static str; 4] = ["std", "boxed", "Box", "new"];

0 commit comments

Comments
 (0)