Skip to content

Commit

Permalink
Rustup to *1.10.0-nightly (22ac88f 2016-05-11)*
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarton committed May 12, 2016
1 parent fe6ad91 commit d274294
Showing 6 changed files with 29 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/cyclomatic_complexity.rs
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ impl CyclomaticComplexity {
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 @@ impl LateLintPass for CyclomaticComplexity {
}
}

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, _) => {
6 changes: 3 additions & 3 deletions src/derive.rs
Original file line number Diff line number Diff line change
@@ -86,15 +86,15 @@ impl LateLintPass for Derive {
}

/// 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()
], {
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 {
@@ -133,7 +133,7 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
let parameter_environment = ty::ParameterEnvironment::for_item(cx.tcx, item.id);
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
}

7 changes: 4 additions & 3 deletions src/escape.rs
Original file line number Diff line number Diff line change
@@ -55,15 +55,16 @@ impl LintPass for EscapePass {
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 mut v = EscapeDelegate {
cx: cx,
set: NodeSet(),
};
{

cx.tcx.infer_ctxt(None, Some(param_env), ProjectionMode::Any).enter(|infcx| {
let mut vis = ExprUseVisitor::new(&mut v, &infcx);
vis.walk_fn(decl, body);
}
});

for node in v.set {
span_lint(cx,
BOXED_LOCAL,
4 changes: 2 additions & 2 deletions src/methods.rs
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ declare_lint! {
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 @@ impl LateLintPass for UnitCmp {
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",
28 changes: 14 additions & 14 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ use reexport::*;
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.
@@ -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:

0 comments on commit d274294

Please sign in to comment.