Merge pull request #2153 from rust-lang-nursery/rustup

rustup to rustc 1.22.0-nightly (b7960878b 2017-10-18)
This commit is contained in:
Oliver Schneider 2017-10-20 09:20:15 +02:00 committed by GitHub
commit ed90843e97
4 changed files with 18 additions and 15 deletions

View file

@ -71,7 +71,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
};
let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
ExprUseVisitor::new(&mut v, cx.tcx, cx.param_env, region_scope_tree, cx.tables).consume_body(body);
ExprUseVisitor::new(&mut v, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).consume_body(body);
for node in v.set {
span_lint(

View file

@ -1390,7 +1390,7 @@ fn check_for_mutation(cx: &LateContext, body: &Expr, bound_ids: &[Option<NodeId>
let mut delegate = MutateDelegate { node_id_low: bound_ids[0], node_id_high: bound_ids[1], span_low: None, span_high: None };
let def_id = def_id::DefId::local(body.hir_id.owner);
let region_scope_tree = &cx.tcx.region_scope_tree(def_id);
ExprUseVisitor::new(&mut delegate, cx.tcx, cx.param_env, region_scope_tree, cx.tables).walk_expr(body);
ExprUseVisitor::new(&mut delegate, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).walk_expr(body);
delegate.mutation_span()
}

View file

@ -821,18 +821,6 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir:
or_has_args: bool,
span: Span,
) {
// don't lint for constant values
// FIXME: can we `expect` here instead of match?
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"),
@ -841,6 +829,21 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir:
(&paths::RESULT, true, &["or", "unwrap_or"], "else"),
];
// early check if the name is one we care about
if know_types.iter().all(|k| !k.2.contains(&name)) {
return;
}
// don't lint for constant values
// FIXME: can we `expect` here instead of match?
let owner_def = cx.tcx.hir.get_parent_did(arg.id);
let promotable = cx.tcx
.rvalue_promotable_map(owner_def)
[&arg.hir_id.local_id];
if promotable {
return;
}
let self_ty = cx.tables.expr_ty(self_expr);
let (fn_has_arguments, poss, suffix) = if let Some(&(_, fn_has_arguments, poss, suffix)) =

View file

@ -108,7 +108,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
} = {
let mut ctx = MovedVariablesCtxt::new(cx);
let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
euv::ExprUseVisitor::new(&mut ctx, cx.tcx, cx.param_env, region_scope_tree, cx.tables).consume_body(body);
euv::ExprUseVisitor::new(&mut ctx, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).consume_body(body);
ctx
};