Skip to content

Update to latest nightly #1715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

## 0.0.130 - 2017-05-01
* Update to *rustc 1.19.0-nightly (6a5fc9eec 2017-05-02)*

## 0.0.129 — 2017-05-01
* Update to *rustc 1.19.0-nightly (06fb4d256 2017-04-30)*

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.129"
version = "0.0.130"
authors = [
"Manish Goregaokar <[email protected]>",
"Andre Bogus <[email protected]>",
Expand Down Expand Up @@ -30,7 +30,7 @@ test = false

[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.129", path = "clippy_lints" }
clippy_lints = { version = "0.0.130", path = "clippy_lints" }
# end automatic update
cargo_metadata = "0.1.1"

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin automatic update
version = "0.0.129"
version = "0.0.130"
# end automatic update
authors = [
"Manish Goregaokar <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
"this boolean expression can be simplified",
|db| for suggestion in &improvements {
db.span_suggestion(e.span, "try", suggest(self.cx, suggestion, &h2q.terminals));
break; // FIXME: multiple suggestions in rustc are broken
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
tcx: self.tcx,
tables: self.tcx.typeck_tables_of(def_id),
needed_resolution: false,
substs,
substs: substs,
};
let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
self.tcx.mir_const_qualif(def_id);
Expand Down
46 changes: 23 additions & 23 deletions clippy_lints/src/eq_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
if let ExprBinary(ref op, ref left, ref right) = e.node {
if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) {
span_lint(cx,
EQ_OP,
e.span,
&format!("equal expressions as operands to `{}`", op.node.as_str()));
EQ_OP,
e.span,
&format!("equal expressions as operands to `{}`", op.node.as_str()));
return;
}
let (trait_id, requires_ref) = match op.node {
Expand Down Expand Up @@ -91,32 +91,30 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
// either operator autorefs or both args are copyable
if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty], None) {
span_lint_and_then(cx,
OP_REF,
e.span,
"needlessly taken reference of both operands",
|db| {
OP_REF,
e.span,
"needlessly taken reference of both operands",
|db| {
let lsnip = snippet(cx, l.span, "...").to_string();
let rsnip = snippet(cx, r.span, "...").to_string();
multispan_sugg(db,
"use the values directly".to_string(),
vec![(left.span, lsnip),
"use the values directly".to_string(),
vec![(left.span, lsnip),
(right.span, rsnip)]);
})
} else if lcpy && !rcpy && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
span_lint_and_then(cx,
OP_REF,
e.span,
"needlessly taken reference of left operand",
|db| {
} else if lcpy && !rcpy &&
implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
let lsnip = snippet(cx, l.span, "...").to_string();
db.span_suggestion(left.span, "use the left value directly", lsnip);
})
} else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
} else if !lcpy && rcpy &&
implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
span_lint_and_then(cx,
OP_REF,
e.span,
"needlessly taken reference of right operand",
|db| {
OP_REF,
e.span,
"needlessly taken reference of right operand",
|db| {
let rsnip = snippet(cx, r.span, "...").to_string();
db.span_suggestion(right.span, "use the right value directly", rsnip);
})
Expand All @@ -126,7 +124,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
(&ExprAddrOf(_, ref l), _) => {
let lty = cx.tables.expr_ty(l);
let lcpy = is_copy(cx, lty, parent);
if (requires_ref || lcpy) && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
if (requires_ref || lcpy) &&
implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
let lsnip = snippet(cx, l.span, "...").to_string();
db.span_suggestion(left.span, "use the left value directly", lsnip);
Expand All @@ -137,10 +136,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
(_, &ExprAddrOf(_, ref r)) => {
let rty = cx.tables.expr_ty(r);
let rcpy = is_copy(cx, rty, parent);
if (requires_ref || rcpy) && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
if (requires_ref || rcpy) &&
implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| {
let rsnip = snippet(cx, r.span, "...").to_string();
db.span_suggestion(left.span, "use the right value directly", rsnip);
db.span_suggestion(right.span, "use the right value directly", rsnip);
})
}
},
Expand Down
8 changes: 5 additions & 3 deletions clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
_: &'tcx FnDecl,
body: &'tcx Body,
_: Span,
_id: NodeId
node_id: NodeId
) {
// we store the infcx because it is expensive to recreate
// the context each time.
Expand All @@ -78,8 +78,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
};

let infcx = cx.tcx.borrowck_fake_infer_ctxt(body.id());
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
let region_maps = &cx.tcx.region_maps(fn_def_id);
{
let mut vis = ExprUseVisitor::new(&mut v, &infcx);
let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx);
vis.consume_body(body);
}

Expand Down Expand Up @@ -150,7 +152,7 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
borrow_id: NodeId,
_: Span,
cmt: cmt<'tcx>,
_: &ty::Region,
_: ty::Region,
_: ty::BorrowKind,
loan_cause: LoanCause
) {
Expand Down
5 changes: 3 additions & 2 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn check_len_zero(cx: &LateContext, span: Span, name: Name, args: &[Expr], lit:
if name == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
span_lint_and_then(cx, LEN_ZERO, span, "length comparison to zero", |db| {
db.span_suggestion(span,
"consider using `is_empty`",
"using `is_empty` is more concise:",
format!("{}{}.is_empty()", op, snippet(cx, args[0].span, "_")));
});
}
Expand All @@ -199,7 +199,8 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {

/// Check the inherent impl's items for an `is_empty(self)` method.
fn has_is_empty_impl(cx: &LateContext, id: DefId) -> bool {
cx.tcx.inherent_impls(id)
cx.tcx
.inherent_impls(id)
.iter()
.any(|imp| cx.tcx.associated_items(*imp).any(|item| is_is_empty(cx, &item)))
}
Expand Down
13 changes: 9 additions & 4 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,11 @@ fn check_for_loop_range<'a, 'tcx>(

// ensure that the indexed variable was declared before the loop, see #601
if let Some(indexed_extent) = indexed_extent {
let pat_extent = cx.tcx.region_maps.var_scope(pat.id);
if cx.tcx.region_maps.is_subscope_of(indexed_extent, pat_extent) {
let parent_id = cx.tcx.hir.get_parent(expr.id);
let parent_def_id = cx.tcx.hir.local_def_id(parent_id);
let region_maps = cx.tcx.region_maps(parent_def_id);
let pat_extent = region_maps.var_scope(pat.id);
if region_maps.is_subscope_of(indexed_extent, pat_extent) {
return;
}
}
Expand Down Expand Up @@ -872,7 +875,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
struct VarVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>, // context reference
var: DefId, // var name to look for as index
indexed: HashMap<Name, Option<CodeExtent>>, // indexed variables, the extent is None for global
indexed: HashMap<Name, Option<CodeExtent<'tcx>>>, // indexed variables, the extent is None for global
nonindex: bool, // has the var been used otherwise?
}

Expand All @@ -895,7 +898,9 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
let def_id = def.def_id();
let node_id = self.cx.tcx.hir.as_local_node_id(def_id).expect("local/upvar are local nodes");

let extent = self.cx.tcx.region_maps.var_scope(node_id);
let parent_id = self.cx.tcx.hir.get_parent(expr.id);
let parent_def_id = self.cx.tcx.hir.local_def_id(parent_id);
let extent = self.cx.tcx.region_maps(parent_def_id).var_scope(node_id);
self.indexed.insert(seqvar.segments[0].name, Some(extent));
return; // no need to walk further
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/misc_early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ impl EarlyLintPass for MiscEarly {
"if you mean to use a decimal constant, remove the `0` to remove confusion:",
src[1..].to_string(),
);
db.span_suggestion(
/*db.span_suggestion(
lit.span,
"if you mean to use an octal constant, use `0o`:",
format!("0o{}", &src[1..]),
);
); FIXME: rustc doesn't support multiple suggestions anymore */
});
}
}}
Expand Down
Loading