Skip to content

Commit f400548

Browse files
authored
Merge pull request #2770 from mati865/rustup
Rustup to 2018-05-16
2 parents 1af2f20 + f0c823a commit f400548

25 files changed

+40
-41
lines changed

clippy_lints/src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ fn is_relevant_block(tcx: TyCtxt, tables: &ty::TypeckTables, block: &Block) -> b
243243

244244
fn is_relevant_expr(tcx: TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool {
245245
match expr.node {
246-
ExprBlock(ref block) => is_relevant_block(tcx, tables, block),
246+
ExprBlock(ref block, _) => is_relevant_block(tcx, tables, block),
247247
ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e),
248248
ExprRet(None) | ExprBreak(_, None) => false,
249249
ExprCall(ref path_expr, _) => if let ExprPath(ref qpath) = path_expr.node {

clippy_lints/src/block_in_if_condition.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
5959
if let ExprClosure(_, _, eid, _, _) = expr.node {
6060
let body = self.cx.tcx.hir.body(eid);
6161
let ex = &body.value;
62-
if matches!(ex.node, ExprBlock(_)) {
62+
if matches!(ex.node, ExprBlock(_, _)) {
6363
self.found_block = Some(ex);
6464
return;
6565
}
@@ -78,7 +78,7 @@ const COMPLEX_BLOCK_MESSAGE: &str = "in an 'if' condition, avoid complex blocks
7878
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
7979
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
8080
if let ExprIf(ref check, ref then, _) = expr.node {
81-
if let ExprBlock(ref block) = check.node {
81+
if let ExprBlock(ref block, _) = check.node {
8282
if block.rules == DefaultBlock {
8383
if block.stmts.is_empty() {
8484
if let Some(ref ex) = block.expr {

clippy_lints/src/bytecount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn check_arg(name: Name, arg: Name, needle: &Expr) -> bool {
9999
fn get_path_name(expr: &Expr) -> Option<Name> {
100100
match expr.node {
101101
ExprBox(ref e) | ExprAddrOf(_, ref e) | ExprUnary(UnOp::UnDeref, ref e) => get_path_name(e),
102-
ExprBlock(ref b) => if b.stmts.is_empty() {
102+
ExprBlock(ref b, _) => if b.stmts.is_empty() {
103103
b.expr.as_ref().and_then(|p| get_path_name(p))
104104
} else {
105105
None

clippy_lints/src/collapsible_if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn check_if(cx: &EarlyContext, expr: &ast::Expr) {
101101

102102
fn check_collapsible_maybe_if_let(cx: &EarlyContext, else_: &ast::Expr) {
103103
if_chain! {
104-
if let ast::ExprKind::Block(ref block) = else_.node;
104+
if let ast::ExprKind::Block(ref block, _) = else_.node;
105105
if let Some(else_) = expr_block(block);
106106
if !in_macro(else_.span);
107107
then {

clippy_lints/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
202202
pub fn expr(&mut self, e: &Expr) -> Option<Constant> {
203203
match e.node {
204204
ExprPath(ref qpath) => self.fetch_path(qpath, e.hir_id),
205-
ExprBlock(ref block) => self.block(block),
205+
ExprBlock(ref block, _) => self.block(block),
206206
ExprIf(ref cond, ref then, ref otherwise) => self.ifthenelse(cond, then, otherwise),
207207
ExprLit(ref lit) => Some(lit_to_constant(&lit.node, self.tables.expr_ty(e))),
208208
ExprArray(ref vec) => self.multi(vec).map(Constant::Vec),

clippy_lints/src/copies.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) {
238238

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

254254
// final `else {..}`
255255
if !blocks.is_empty() {
256-
if let ExprBlock(ref block) = expr.node {
256+
if let ExprBlock(ref block, _) = expr.node {
257257
blocks.push(&**block);
258258
}
259259
}

clippy_lints/src/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HashMapLint {
4747
// in case of `if !m.contains_key(&k) { m.insert(k, v); }`
4848
// we can give a better error message
4949
let sole_expr = {
50-
else_block.is_none() && if let ExprBlock(ref then_block) = then_block.node {
50+
else_block.is_none() && if let ExprBlock(ref then_block, _) = then_block.node {
5151
(then_block.expr.is_some() as usize) + then_block.stmts.len() == 1
5252
} else {
5353
true

clippy_lints/src/infinite_iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
160160
}
161161
Finite
162162
},
163-
ExprBlock(ref block) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
163+
ExprBlock(ref block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
164164
ExprBox(ref e) | ExprAddrOf(_, ref e) => is_infinite(cx, e),
165165
ExprCall(ref path, _) => if let ExprPath(ref qpath) = path.node {
166166
match_qpath(qpath, &paths::REPEAT).into()

clippy_lints/src/let_if_seq.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
7171
if let hir::StmtExpr(ref if_, _) = expr.node;
7272
if let hir::ExprIf(ref cond, ref then, ref else_) = if_.node;
7373
if !used_in_expr(cx, canonical_id, cond);
74-
if let hir::ExprBlock(ref then) = then.node;
74+
if let hir::ExprBlock(ref then, _) = then.node;
7575
if let Some(value) = check_assign(cx, canonical_id, &*then);
7676
if !used_in_expr(cx, canonical_id, value);
7777
then {
7878
let span = stmt.span.to(if_.span);
7979

8080
let (default_multi_stmts, default) = if let Some(ref else_) = *else_ {
81-
if let hir::ExprBlock(ref else_) = else_.node {
81+
if let hir::ExprBlock(ref else_, _) = else_.node {
8282
if let Some(default) = check_assign(cx, canonical_id, else_) {
8383
(else_.stmts.len() > 1, default)
8484
} else if let Some(ref default) = decl.init {

clippy_lints/src/lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,13 @@ impl<'v, 't> RefVisitor<'v, 't> {
296296
match self.cx.tables.qpath_def(qpath, hir_id) {
297297
Def::TyAlias(def_id) | Def::Struct(def_id) => {
298298
let generics = self.cx.tcx.generics_of(def_id);
299-
for _ in generics.regions.as_slice() {
299+
for _ in generics.params.as_slice() {
300300
self.record(&None);
301301
}
302302
},
303303
Def::Trait(def_id) => {
304304
let trait_def = self.cx.tcx.trait_def(def_id);
305-
for _ in &self.cx.tcx.generics_of(trait_def.def_id).regions {
305+
for _ in &self.cx.tcx.generics_of(trait_def.def_id).params {
306306
self.record(&None);
307307
}
308308
},

clippy_lints/src/loops.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,9 @@ fn never_loop_expr(expr: &Expr, main_loop_id: &NodeId) -> NeverLoopResult {
638638
combine_seq(e, arms)
639639
}
640640
},
641-
ExprBlock(ref b) => never_loop_block(b, main_loop_id),
641+
ExprBlock(ref b, _) => never_loop_block(b, main_loop_id),
642642
ExprAgain(d) => {
643643
let id = d.target_id
644-
.opt_id()
645644
.expect("target id can only be missing in the presence of compilation errors");
646645
if id == *main_loop_id {
647646
NeverLoopResult::MayContinueMainLoop
@@ -849,7 +848,7 @@ fn get_indexed_assignments<'a, 'tcx>(
849848
}
850849
}
851850

852-
if let Expr_::ExprBlock(ref b) = body.node {
851+
if let Expr_::ExprBlock(ref b, _) = body.node {
853852
let Block {
854853
ref stmts,
855854
ref expr,
@@ -1842,7 +1841,7 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> {
18421841
fn is_simple_break_expr(expr: &Expr) -> bool {
18431842
match expr.node {
18441843
ExprBreak(dest, ref passed_expr) if dest.label.is_none() && passed_expr.is_none() => true,
1845-
ExprBlock(ref b) => match extract_first_expr(b) {
1844+
ExprBlock(ref b, _) => match extract_first_expr(b) {
18461845
Some(subexpr) => is_simple_break_expr(subexpr),
18471846
None => false,
18481847
},

clippy_lints/src/map_unit_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext, expr: &'a hir::Expr) -> Option<S
120120
// Calls can't be reduced any more
121121
Some(expr.span)
122122
},
123-
hir::ExprBlock(ref block) => {
123+
hir::ExprBlock(ref block, _) => {
124124
match (&block.stmts[..], block.expr.as_ref()) {
125125
(&[], Some(inner_expr)) => {
126126
// If block only contains an expression,

clippy_lints/src/matches.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fn check_single_match(cx: &LateContext, ex: &Expr, arms: &[Arm], expr: &Expr) {
205205
let els = remove_blocks(&arms[1].body);
206206
let els = if is_unit_expr(els) {
207207
None
208-
} else if let ExprBlock(_) = els.node {
208+
} else if let ExprBlock(_, _) = els.node {
209209
// matches with blocks that contain statements are prettier as `if let + else`
210210
Some(els)
211211
} else {
@@ -365,7 +365,7 @@ fn check_wild_err_arm(cx: &LateContext, ex: &Expr, arms: &[Arm]) {
365365
if_chain! {
366366
if path_str == "Err";
367367
if inner.iter().any(|pat| pat.node == PatKind::Wild);
368-
if let ExprBlock(ref block) = arm.body.node;
368+
if let ExprBlock(ref block, _) = arm.body.node;
369369
if is_panic_block(block);
370370
then {
371371
// `Err(_)` arm with `panic!` found
@@ -534,7 +534,7 @@ fn type_ranges(ranges: &[SpannedRange<Constant>]) -> TypedRanges {
534534
fn is_unit_expr(expr: &Expr) -> bool {
535535
match expr.node {
536536
ExprTup(ref v) if v.is_empty() => true,
537-
ExprBlock(ref b) if b.stmts.is_empty() && b.expr.is_none() => true,
537+
ExprBlock(ref b, _) if b.stmts.is_empty() && b.expr.is_none() => true,
538538
_ => false,
539539
}
540540
}

clippy_lints/src/needless_bool.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
8080
hint,
8181
);
8282
};
83-
if let ExprBlock(ref then_block) = then_block.node {
83+
if let ExprBlock(ref then_block, _) = then_block.node {
8484
match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
8585
(RetBool(true), RetBool(true)) | (Bool(true), Bool(true)) => {
8686
span_lint(
@@ -199,7 +199,7 @@ fn fetch_bool_block(block: &Block) -> Expression {
199199

200200
fn fetch_bool_expr(expr: &Expr) -> Expression {
201201
match expr.node {
202-
ExprBlock(ref block) => fetch_bool_block(block),
202+
ExprBlock(ref block, _) => fetch_bool_block(block),
203203
ExprLit(ref lit_ptr) => if let LitKind::Bool(value) = lit_ptr.node {
204204
Expression::Bool(value)
205205
} else {

clippy_lints/src/needless_continue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl EarlyLintPass for NeedlessContinue {
173173
///
174174
fn needless_continue_in_else(else_expr: &ast::Expr) -> bool {
175175
match else_expr.node {
176-
ast::ExprKind::Block(ref else_block) => is_first_block_stmt_continue(else_block),
176+
ast::ExprKind::Block(ref else_block, _) => is_first_block_stmt_continue(else_block),
177177
ast::ExprKind::Continue(_) => true,
178178
_ => false,
179179
}

clippy_lints/src/no_effect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn has_no_effect(cx: &LateContext, expr: &Expr) -> bool {
7575
} else {
7676
false
7777
},
78-
Expr_::ExprBlock(ref block) => {
78+
Expr_::ExprBlock(ref block, _) => {
7979
block.stmts.is_empty() && if let Some(ref expr) = block.expr {
8080
has_no_effect(cx, expr)
8181
} else {
@@ -169,7 +169,7 @@ fn reduce_expression<'a>(cx: &LateContext, expr: &'a Expr) -> Option<Vec<&'a Exp
169169
} else {
170170
None
171171
},
172-
Expr_::ExprBlock(ref block) => {
172+
Expr_::ExprBlock(ref block, _) => {
173173
if block.stmts.is_empty() {
174174
block.expr.as_ref().and_then(|e| {
175175
match block.rules {

clippy_lints/src/panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl LintPass for Pass {
3434
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
3535
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
3636
if_chain! {
37-
if let ExprBlock(ref block) = expr.node;
37+
if let ExprBlock(ref block, _) = expr.node;
3838
if let Some(ref ex) = block.expr;
3939
if let ExprCall(ref fun, ref params) = ex.node;
4040
if params.len() == 2;

clippy_lints/src/question_mark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl QuestionMarkPass {
8787

8888
fn expression_returns_none(cx: &LateContext, expression: &Expr) -> bool {
8989
match expression.node {
90-
ExprBlock(ref block) => {
90+
ExprBlock(ref block, _) => {
9191
if let Some(return_expression) = Self::return_expression(block) {
9292
return Self::expression_returns_none(cx, &return_expression);
9393
}

clippy_lints/src/returns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl ReturnPass {
6969
}
7070
},
7171
// a whole block? check it!
72-
ast::ExprKind::Block(ref block) => {
72+
ast::ExprKind::Block(ref block, _) => {
7373
self.check_block_return(cx, block);
7474
},
7575
// an if/if let expr, check both exprs

clippy_lints/src/shadow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings:
309309
ExprUnary(_, ref e) | ExprField(ref e, _) | ExprAddrOf(_, ref e) | ExprBox(ref e) => {
310310
check_expr(cx, e, bindings)
311311
},
312-
ExprBlock(ref block) | ExprLoop(ref block, _, _) => check_block(cx, block, bindings),
312+
ExprBlock(ref block, _) | ExprLoop(ref block, _, _) => check_block(cx, block, bindings),
313313
// ExprCall
314314
// ExprMethodCall
315315
ExprArray(ref v) | ExprTup(ref v) => for e in v {
@@ -364,7 +364,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut V
364364
fn is_self_shadow(name: Name, expr: &Expr) -> bool {
365365
match expr.node {
366366
ExprBox(ref inner) | ExprAddrOf(_, ref inner) => is_self_shadow(name, inner),
367-
ExprBlock(ref block) => {
367+
ExprBlock(ref block, _) => {
368368
block.stmts.is_empty()
369369
&& block
370370
.expr

clippy_lints/src/strings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn is_string(cx: &LateContext, e: &Expr) -> bool {
123123
fn is_add(cx: &LateContext, src: &Expr, target: &Expr) -> bool {
124124
match src.node {
125125
ExprBinary(Spanned { node: BiAdd, .. }, ref left, _) => SpanlessEq::new(cx).eq_expr(target, left),
126-
ExprBlock(ref block) => {
126+
ExprBlock(ref block, _) => {
127127
block.stmts.is_empty()
128128
&& block
129129
.expr

clippy_lints/src/utils/author.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
356356
self.current = sub_pat;
357357
self.visit_expr(sub);
358358
},
359-
Expr_::ExprBlock(ref block) => {
359+
Expr_::ExprBlock(ref block, _) => {
360360
let block_pat = self.next("block");
361361
println!("Block(ref {}) = {};", block_pat, current);
362362
self.current = block_pat;

clippy_lints/src/utils/hir_utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
7979
(&ExprAssignOp(ref lo, ref ll, ref lr), &ExprAssignOp(ref ro, ref rl, ref rr)) => {
8080
lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
8181
},
82-
(&ExprBlock(ref l), &ExprBlock(ref r)) => self.eq_block(l, r),
82+
(&ExprBlock(ref l, _), &ExprBlock(ref r, _)) => self.eq_block(l, r),
8383
(&ExprBinary(l_op, ref ll, ref lr), &ExprBinary(r_op, ref rl, ref rr)) => {
8484
l_op.node == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
8585
|| swap_binop(l_op.node, ll, lr).map_or(false, |(l_op, ll, lr)| {
@@ -353,8 +353,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
353353
self.hash_expr(l);
354354
self.hash_expr(r);
355355
},
356-
ExprBlock(ref b) => {
357-
let c: fn(_) -> _ = ExprBlock;
356+
ExprBlock(ref b, _) => {
357+
let c: fn(_, _) -> _ = ExprBlock;
358358
c.hash(&mut self.s);
359359
self.hash_block(b);
360360
},

clippy_lints/src/utils/inspector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
250250
println!("{}Yield", ind);
251251
print_expr(cx, sub, indent + 1);
252252
},
253-
hir::ExprBlock(_) => {
253+
hir::ExprBlock(_, _) => {
254254
println!("{}Block", ind);
255255
},
256256
hir::ExprAssign(ref lhs, ref rhs) => {

clippy_lints/src/utils/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ pub fn expr_block<'a, 'b, T: LintContext<'b>>(
444444
) -> Cow<'a, str> {
445445
let code = snippet_block(cx, expr.span, default);
446446
let string = option.unwrap_or_default();
447-
if let ExprBlock(_) = expr.node {
447+
if let ExprBlock(_, _) = expr.node {
448448
Cow::Owned(format!("{}{}", code, string))
449449
} else if string.is_empty() {
450450
Cow::Owned(format!("{{ {} }}", code))
@@ -529,7 +529,7 @@ pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, node: NodeI
529529
node: ImplItemKind::Method(_, eid),
530530
..
531531
}) => match cx.tcx.hir.body(eid).value.node {
532-
ExprBlock(ref block) => Some(block),
532+
ExprBlock(ref block, _) => Some(block),
533533
_ => None,
534534
},
535535
_ => None,
@@ -934,7 +934,7 @@ pub fn is_automatically_derived(attrs: &[ast::Attribute]) -> bool {
934934
/// Ie. `x`, `{ x }` and `{{{{ x }}}}` all give `x`. `{ x; y }` and `{}` return
935935
/// themselves.
936936
pub fn remove_blocks(expr: &Expr) -> &Expr {
937-
if let ExprBlock(ref block) = expr.node {
937+
if let ExprBlock(ref block, _) = expr.node {
938938
if block.stmts.is_empty() {
939939
if let Some(ref expr) = block.expr {
940940
remove_blocks(expr)

0 commit comments

Comments
 (0)