From a2257280ecab8692795098ac02198e98e7d00efc Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 13 Sep 2016 12:41:20 +0200 Subject: [PATCH] don't lint expressions referencing `!` objects, just expressions creating them --- clippy_lints/src/eval_order_dependence.rs | 7 ++----- tests/compile-fail/diverging_sub_expression.rs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index d6964c156..f357cd8f6 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -122,9 +122,6 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> { impl<'a, 'tcx, 'v> Visitor<'v> for DivergenceVisitor<'a, 'tcx> { fn visit_expr(&mut self, e: &'v Expr) { - // this match can be replaced by just the default arm, once - // https://github.com/rust-lang/rust/issues/35121 makes sure that - // ! is propagated properly match e.node { ExprAgain(_) | ExprBreak(_) | @@ -137,8 +134,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DivergenceVisitor<'a, 'tcx> { _ => {}, }, ExprMethodCall(..) => { /* TODO */ }, - _ => if let ty::TyNever = self.0.tcx.expr_ty(e).sty { - self.report_diverging_sub_expr(e); + _ => { + // do not lint expressions referencing objects of type `!`, as that required a diverging expression to begin with }, } self.maybe_walk_expr(e); diff --git a/tests/compile-fail/diverging_sub_expression.rs b/tests/compile-fail/diverging_sub_expression.rs index 929ef911f..20b284732 100644 --- a/tests/compile-fail/diverging_sub_expression.rs +++ b/tests/compile-fail/diverging_sub_expression.rs @@ -10,5 +10,5 @@ fn main() { let b = true; b || diverge(); //~ ERROR sub-expression diverges let y = (5, diverge(), 6); //~ ERROR sub-expression diverges - println!("{}", y.1); //~ ERROR sub-expression diverges + println!("{}", y.1); }