Skip to content
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

Rustup to 2018-05-16 #2770

Merged
merged 1 commit into from
May 17, 2018
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
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ fn is_relevant_block(tcx: TyCtxt, tables: &ty::TypeckTables, block: &Block) -> b

fn is_relevant_expr(tcx: TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool {
match expr.node {
ExprBlock(ref block) => is_relevant_block(tcx, tables, block),
ExprBlock(ref block, _) => is_relevant_block(tcx, tables, block),
ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e),
ExprRet(None) | ExprBreak(_, None) => false,
ExprCall(ref path_expr, _) => if let ExprPath(ref qpath) = path_expr.node {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/block_in_if_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
if let ExprClosure(_, _, eid, _, _) = expr.node {
let body = self.cx.tcx.hir.body(eid);
let ex = &body.value;
if matches!(ex.node, ExprBlock(_)) {
if matches!(ex.node, ExprBlock(_, _)) {
self.found_block = Some(ex);
return;
}
Expand All @@ -78,7 +78,7 @@ const COMPLEX_BLOCK_MESSAGE: &str = "in an 'if' condition, avoid complex blocks
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
if let ExprIf(ref check, ref then, _) = expr.node {
if let ExprBlock(ref block) = check.node {
if let ExprBlock(ref block, _) = check.node {
if block.rules == DefaultBlock {
if block.stmts.is_empty() {
if let Some(ref ex) = block.expr {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn check_arg(name: Name, arg: Name, needle: &Expr) -> bool {
fn get_path_name(expr: &Expr) -> Option<Name> {
match expr.node {
ExprBox(ref e) | ExprAddrOf(_, ref e) | ExprUnary(UnOp::UnDeref, ref e) => get_path_name(e),
ExprBlock(ref b) => if b.stmts.is_empty() {
ExprBlock(ref b, _) => if b.stmts.is_empty() {
b.expr.as_ref().and_then(|p| get_path_name(p))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn check_if(cx: &EarlyContext, expr: &ast::Expr) {

fn check_collapsible_maybe_if_let(cx: &EarlyContext, else_: &ast::Expr) {
if_chain! {
if let ast::ExprKind::Block(ref block) = else_.node;
if let ast::ExprKind::Block(ref block, _) = else_.node;
if let Some(else_) = expr_block(block);
if !in_macro(else_.span);
then {
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 @@ -202,7 +202,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
pub fn expr(&mut self, e: &Expr) -> Option<Constant> {
match e.node {
ExprPath(ref qpath) => self.fetch_path(qpath, e.hir_id),
ExprBlock(ref block) => self.block(block),
ExprBlock(ref block, _) => self.block(block),
ExprIf(ref cond, ref then, ref otherwise) => self.ifthenelse(cond, then, otherwise),
ExprLit(ref lit) => Some(lit_to_constant(&lit.node, self.tables.expr_ty(e))),
ExprArray(ref vec) => self.multi(vec).map(Constant::Vec),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) {

while let ExprIf(ref cond, ref then_expr, ref else_expr) = expr.node {
conds.push(&**cond);
if let ExprBlock(ref block) = then_expr.node {
if let ExprBlock(ref block, _) = then_expr.node {
blocks.push(block);
} else {
panic!("ExprIf node is not an ExprBlock");
Expand All @@ -253,7 +253,7 @@ fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) {

// final `else {..}`
if !blocks.is_empty() {
if let ExprBlock(ref block) = expr.node {
if let ExprBlock(ref block, _) = expr.node {
blocks.push(&**block);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HashMapLint {
// in case of `if !m.contains_key(&k) { m.insert(k, v); }`
// we can give a better error message
let sole_expr = {
else_block.is_none() && if let ExprBlock(ref then_block) = then_block.node {
else_block.is_none() && if let ExprBlock(ref then_block, _) = then_block.node {
(then_block.expr.is_some() as usize) + then_block.stmts.len() == 1
} else {
true
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/infinite_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
}
Finite
},
ExprBlock(ref block) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
ExprBlock(ref block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
ExprBox(ref e) | ExprAddrOf(_, ref e) => is_infinite(cx, e),
ExprCall(ref path, _) => if let ExprPath(ref qpath) = path.node {
match_qpath(qpath, &paths::REPEAT).into()
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
if let hir::StmtExpr(ref if_, _) = expr.node;
if let hir::ExprIf(ref cond, ref then, ref else_) = if_.node;
if !used_in_expr(cx, canonical_id, cond);
if let hir::ExprBlock(ref then) = then.node;
if let hir::ExprBlock(ref then, _) = then.node;
if let Some(value) = check_assign(cx, canonical_id, &*then);
if !used_in_expr(cx, canonical_id, value);
then {
let span = stmt.span.to(if_.span);

let (default_multi_stmts, default) = if let Some(ref else_) = *else_ {
if let hir::ExprBlock(ref else_) = else_.node {
if let hir::ExprBlock(ref else_, _) = else_.node {
if let Some(default) = check_assign(cx, canonical_id, else_) {
(else_.stmts.len() > 1, default)
} else if let Some(ref default) = decl.init {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,13 @@ impl<'v, 't> RefVisitor<'v, 't> {
match self.cx.tables.qpath_def(qpath, hir_id) {
Def::TyAlias(def_id) | Def::Struct(def_id) => {
let generics = self.cx.tcx.generics_of(def_id);
for _ in generics.regions.as_slice() {
for _ in generics.params.as_slice() {
self.record(&None);
}
},
Def::Trait(def_id) => {
let trait_def = self.cx.tcx.trait_def(def_id);
for _ in &self.cx.tcx.generics_of(trait_def.def_id).regions {
for _ in &self.cx.tcx.generics_of(trait_def.def_id).params {
self.record(&None);
}
},
Expand Down
7 changes: 3 additions & 4 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,9 @@ fn never_loop_expr(expr: &Expr, main_loop_id: &NodeId) -> NeverLoopResult {
combine_seq(e, arms)
}
},
ExprBlock(ref b) => never_loop_block(b, main_loop_id),
ExprBlock(ref b, _) => never_loop_block(b, main_loop_id),
ExprAgain(d) => {
let id = d.target_id
.opt_id()
.expect("target id can only be missing in the presence of compilation errors");
if id == *main_loop_id {
NeverLoopResult::MayContinueMainLoop
Expand Down Expand Up @@ -849,7 +848,7 @@ fn get_indexed_assignments<'a, 'tcx>(
}
}

if let Expr_::ExprBlock(ref b) = body.node {
if let Expr_::ExprBlock(ref b, _) = body.node {
let Block {
ref stmts,
ref expr,
Expand Down Expand Up @@ -1842,7 +1841,7 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> {
fn is_simple_break_expr(expr: &Expr) -> bool {
match expr.node {
ExprBreak(dest, ref passed_expr) if dest.label.is_none() && passed_expr.is_none() => true,
ExprBlock(ref b) => match extract_first_expr(b) {
ExprBlock(ref b, _) => match extract_first_expr(b) {
Some(subexpr) => is_simple_break_expr(subexpr),
None => false,
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/map_unit_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext, expr: &'a hir::Expr) -> Option<S
// Calls can't be reduced any more
Some(expr.span)
},
hir::ExprBlock(ref block) => {
hir::ExprBlock(ref block, _) => {
match (&block.stmts[..], block.expr.as_ref()) {
(&[], Some(inner_expr)) => {
// If block only contains an expression,
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ fn check_single_match(cx: &LateContext, ex: &Expr, arms: &[Arm], expr: &Expr) {
let els = remove_blocks(&arms[1].body);
let els = if is_unit_expr(els) {
None
} else if let ExprBlock(_) = els.node {
} else if let ExprBlock(_, _) = els.node {
// matches with blocks that contain statements are prettier as `if let + else`
Some(els)
} else {
Expand Down Expand Up @@ -365,7 +365,7 @@ fn check_wild_err_arm(cx: &LateContext, ex: &Expr, arms: &[Arm]) {
if_chain! {
if path_str == "Err";
if inner.iter().any(|pat| pat.node == PatKind::Wild);
if let ExprBlock(ref block) = arm.body.node;
if let ExprBlock(ref block, _) = arm.body.node;
if is_panic_block(block);
then {
// `Err(_)` arm with `panic!` found
Expand Down Expand Up @@ -534,7 +534,7 @@ fn type_ranges(ranges: &[SpannedRange<Constant>]) -> TypedRanges {
fn is_unit_expr(expr: &Expr) -> bool {
match expr.node {
ExprTup(ref v) if v.is_empty() => true,
ExprBlock(ref b) if b.stmts.is_empty() && b.expr.is_none() => true,
ExprBlock(ref b, _) if b.stmts.is_empty() && b.expr.is_none() => true,
_ => false,
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/needless_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
hint,
);
};
if let ExprBlock(ref then_block) = then_block.node {
if let ExprBlock(ref then_block, _) = then_block.node {
match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
(RetBool(true), RetBool(true)) | (Bool(true), Bool(true)) => {
span_lint(
Expand Down Expand Up @@ -199,7 +199,7 @@ fn fetch_bool_block(block: &Block) -> Expression {

fn fetch_bool_expr(expr: &Expr) -> Expression {
match expr.node {
ExprBlock(ref block) => fetch_bool_block(block),
ExprBlock(ref block, _) => fetch_bool_block(block),
ExprLit(ref lit_ptr) => if let LitKind::Bool(value) = lit_ptr.node {
Expression::Bool(value)
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl EarlyLintPass for NeedlessContinue {
///
fn needless_continue_in_else(else_expr: &ast::Expr) -> bool {
match else_expr.node {
ast::ExprKind::Block(ref else_block) => is_first_block_stmt_continue(else_block),
ast::ExprKind::Block(ref else_block, _) => is_first_block_stmt_continue(else_block),
ast::ExprKind::Continue(_) => true,
_ => false,
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/no_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn has_no_effect(cx: &LateContext, expr: &Expr) -> bool {
} else {
false
},
Expr_::ExprBlock(ref block) => {
Expr_::ExprBlock(ref block, _) => {
block.stmts.is_empty() && if let Some(ref expr) = block.expr {
has_no_effect(cx, expr)
} else {
Expand Down Expand Up @@ -169,7 +169,7 @@ fn reduce_expression<'a>(cx: &LateContext, expr: &'a Expr) -> Option<Vec<&'a Exp
} else {
None
},
Expr_::ExprBlock(ref block) => {
Expr_::ExprBlock(ref block, _) => {
if block.stmts.is_empty() {
block.expr.as_ref().and_then(|e| {
match block.rules {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl LintPass for Pass {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
if_chain! {
if let ExprBlock(ref block) = expr.node;
if let ExprBlock(ref block, _) = expr.node;
if let Some(ref ex) = block.expr;
if let ExprCall(ref fun, ref params) = ex.node;
if params.len() == 2;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/question_mark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl QuestionMarkPass {

fn expression_returns_none(cx: &LateContext, expression: &Expr) -> bool {
match expression.node {
ExprBlock(ref block) => {
ExprBlock(ref block, _) => {
if let Some(return_expression) = Self::return_expression(block) {
return Self::expression_returns_none(cx, &return_expression);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/returns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl ReturnPass {
}
},
// a whole block? check it!
ast::ExprKind::Block(ref block) => {
ast::ExprKind::Block(ref block, _) => {
self.check_block_return(cx, block);
},
// an if/if let expr, check both exprs
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings:
ExprUnary(_, ref e) | ExprField(ref e, _) | ExprAddrOf(_, ref e) | ExprBox(ref e) => {
check_expr(cx, e, bindings)
},
ExprBlock(ref block) | ExprLoop(ref block, _, _) => check_block(cx, block, bindings),
ExprBlock(ref block, _) | ExprLoop(ref block, _, _) => check_block(cx, block, bindings),
// ExprCall
// ExprMethodCall
ExprArray(ref v) | ExprTup(ref v) => for e in v {
Expand Down Expand Up @@ -364,7 +364,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut V
fn is_self_shadow(name: Name, expr: &Expr) -> bool {
match expr.node {
ExprBox(ref inner) | ExprAddrOf(_, ref inner) => is_self_shadow(name, inner),
ExprBlock(ref block) => {
ExprBlock(ref block, _) => {
block.stmts.is_empty()
&& block
.expr
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn is_string(cx: &LateContext, e: &Expr) -> bool {
fn is_add(cx: &LateContext, src: &Expr, target: &Expr) -> bool {
match src.node {
ExprBinary(Spanned { node: BiAdd, .. }, ref left, _) => SpanlessEq::new(cx).eq_expr(target, left),
ExprBlock(ref block) => {
ExprBlock(ref block, _) => {
block.stmts.is_empty()
&& block
.expr
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
self.current = sub_pat;
self.visit_expr(sub);
},
Expr_::ExprBlock(ref block) => {
Expr_::ExprBlock(ref block, _) => {
let block_pat = self.next("block");
println!("Block(ref {}) = {};", block_pat, current);
self.current = block_pat;
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/utils/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
(&ExprAssignOp(ref lo, ref ll, ref lr), &ExprAssignOp(ref ro, ref rl, ref rr)) => {
lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
},
(&ExprBlock(ref l), &ExprBlock(ref r)) => self.eq_block(l, r),
(&ExprBlock(ref l, _), &ExprBlock(ref r, _)) => self.eq_block(l, r),
(&ExprBinary(l_op, ref ll, ref lr), &ExprBinary(r_op, ref rl, ref rr)) => {
l_op.node == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
|| swap_binop(l_op.node, ll, lr).map_or(false, |(l_op, ll, lr)| {
Expand Down Expand Up @@ -353,8 +353,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_expr(l);
self.hash_expr(r);
},
ExprBlock(ref b) => {
let c: fn(_) -> _ = ExprBlock;
ExprBlock(ref b, _) => {
let c: fn(_, _) -> _ = ExprBlock;
c.hash(&mut self.s);
self.hash_block(b);
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
println!("{}Yield", ind);
print_expr(cx, sub, indent + 1);
},
hir::ExprBlock(_) => {
hir::ExprBlock(_, _) => {
println!("{}Block", ind);
},
hir::ExprAssign(ref lhs, ref rhs) => {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ pub fn expr_block<'a, 'b, T: LintContext<'b>>(
) -> Cow<'a, str> {
let code = snippet_block(cx, expr.span, default);
let string = option.unwrap_or_default();
if let ExprBlock(_) = expr.node {
if let ExprBlock(_, _) = expr.node {
Cow::Owned(format!("{}{}", code, string))
} else if string.is_empty() {
Cow::Owned(format!("{{ {} }}", code))
Expand Down Expand Up @@ -529,7 +529,7 @@ pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, node: NodeI
node: ImplItemKind::Method(_, eid),
..
}) => match cx.tcx.hir.body(eid).value.node {
ExprBlock(ref block) => Some(block),
ExprBlock(ref block, _) => Some(block),
_ => None,
},
_ => None,
Expand Down Expand Up @@ -934,7 +934,7 @@ pub fn is_automatically_derived(attrs: &[ast::Attribute]) -> bool {
/// Ie. `x`, `{ x }` and `{{{{ x }}}}` all give `x`. `{ x; y }` and `{}` return
/// themselves.
pub fn remove_blocks(expr: &Expr) -> &Expr {
if let ExprBlock(ref block) = expr.node {
if let ExprBlock(ref block, _) = expr.node {
if block.stmts.is_empty() {
if let Some(ref expr) = block.expr {
remove_blocks(expr)
Expand Down