From 24e856f10a6e7b623fb1e1674bb158bbb339b881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 1 May 2019 22:18:05 +0200 Subject: [PATCH 1/2] rustup https://github.com/rust-lang/rust/pull/60417/ cc https://github.com/rust-lang/rust/issues/60448 --- clippy_lints/src/loops.rs | 2 +- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/hir_utils.rs | 6 +++--- clippy_lints/src/utils/inspector.rs | 2 +- clippy_lints/src/utils/sugg.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 1f6501f74e7..d82be14e40c 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -677,7 +677,7 @@ fn never_loop_expr(expr: &Expr, main_loop_id: HirId) -> NeverLoopResult { | ExprKind::AddrOf(_, ref e) | ExprKind::Struct(_, _, Some(ref e)) | ExprKind::Repeat(ref e, _) - | ExprKind::Use(ref e) => never_loop_expr(e, main_loop_id), + | ExprKind::DropTemps(ref e) => never_loop_expr(e, main_loop_id), ExprKind::Array(ref es) | ExprKind::MethodCall(_, _, ref es) | ExprKind::Tup(ref es) => { never_loop_expr_all(&mut es.iter(), main_loop_id) }, diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 3936473f725..729b2202d80 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -495,7 +495,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { ExprKind::Err => { println!("Err = {}", current); }, - ExprKind::Use(ref expr) => { + ExprKind::DropTemps(ref expr) => { let expr_pat = self.next("expr"); println!("Use(ref {}) = {};", expr_pat, current); self.current = expr_pat; diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 71f84d6910f..d915e8fdedd 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -156,7 +156,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.as_str() == r.ident.as_str()) }, - (&ExprKind::Use(ref le), &ExprKind::Use(ref re)) => self.eq_expr(le, re), + (&ExprKind::DropTemps(ref le), &ExprKind::DropTemps(ref re)) => self.eq_expr(le, re), _ => false, } } @@ -607,8 +607,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { } }, ExprKind::Err => {}, - ExprKind::Use(ref e) => { - let c: fn(_) -> _ = ExprKind::Use; + ExprKind::DropTemps(ref e) => { + let c: fn(_) -> _ = ExprKind::DropTemps; c.hash(&mut self.s); self.hash_expr(e); }, diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 02725e51060..6cd595607d3 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -330,7 +330,7 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) { hir::ExprKind::Err => { println!("{}Err", ind); }, - hir::ExprKind::Use(ref e) => { + hir::ExprKind::DropTemps(ref e) => { println!("{}Use", ind); print_expr(cx, e, indent + 1); }, diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index acb996a3c9b..3fa08e0a11c 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -115,7 +115,7 @@ impl<'a> Sugg<'a> { | hir::ExprKind::Struct(..) | hir::ExprKind::Tup(..) | hir::ExprKind::While(..) - | hir::ExprKind::Use(_) + | hir::ExprKind::DropTemps(_) | hir::ExprKind::Err => Sugg::NonParen(snippet), hir::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet), hir::ExprKind::AssignOp(op, ..) => Sugg::BinOp(hirbinop2assignop(op), snippet), From f195680edb1d0ba2c04bfd6ba4fccfca184e8dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 1 May 2019 22:52:19 +0200 Subject: [PATCH 2/2] more Use->DropTemps fixes --- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/inspector.rs | 2 +- tests/ui/author/for_loop.stdout | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 729b2202d80..63f94628630 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -497,7 +497,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { }, ExprKind::DropTemps(ref expr) => { let expr_pat = self.next("expr"); - println!("Use(ref {}) = {};", expr_pat, current); + println!("DropTemps(ref {}) = {};", expr_pat, current); self.current = expr_pat; self.visit_expr(expr); }, diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 6cd595607d3..cde911940dc 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -331,7 +331,7 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) { println!("{}Err", ind); }, hir::ExprKind::DropTemps(ref e) => { - println!("{}Use", ind); + println!("{}DropTemps", ind); print_expr(cx, e, indent + 1); }, } diff --git a/tests/ui/author/for_loop.stdout b/tests/ui/author/for_loop.stdout index 9402705355c..a9651c2f718 100644 --- a/tests/ui/author/for_loop.stdout +++ b/tests/ui/author/for_loop.stdout @@ -1,5 +1,5 @@ if_chain! { - if let ExprKind::Use(ref expr) = expr.node; + if let ExprKind::DropTemps(ref expr) = expr.node; if let ExprKind::Match(ref expr1, ref arms, MatchSource::ForLoopDesugar) = expr.node; if let ExprKind::Call(ref func, ref args) = expr1.node; if let ExprKind::Path(ref path) = func.node;