From 4d66b65850cba7302c79c031f9fa61e7162aca43 Mon Sep 17 00:00:00 2001 From: varkor Date: Sun, 1 Jul 2018 23:40:03 +0100 Subject: [PATCH] Fix issue-50585 test --- src/librustc_passes/loops.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index 898acf48d3d..eff0dbe1235 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -17,7 +17,7 @@ use rustc::hir::{self, Destination}; use syntax::ast; use syntax_pos::Span; -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq)] enum LoopKind { Loop(hir::LoopSource), WhileLoop, @@ -34,7 +34,7 @@ impl LoopKind { } } -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq)] enum Context { Normal, Loop(LoopKind), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index fa78b38dbb7..646c4f17568 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3827,7 +3827,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // this can only happen if the `break` was not // inside a loop at all, which is caught by the // loop-checking pass. - assert!(self.tcx.sess.err_count() > 0); + if self.tcx.sess.err_count() == 0 { + self.tcx.sess.delay_span_bug(expr.span, + "break was outside loop, but no error was emitted"); + } // We still need to assign a type to the inner expression to // prevent the ICE in #43162. @@ -3960,7 +3963,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // is nil. This makes sense because infinite loops // (which would have type !) are only possible iff we // permit break with a value [1]. - assert!(ctxt.coerce.is_some() || ctxt.may_break); // [1] + if ctxt.coerce.is_none() && !ctxt.may_break { + // [1] + self.tcx.sess.delay_span_bug(body.span, "no coercion, but loop may not break"); + } ctxt.coerce.map(|c| c.complete(self)).unwrap_or(self.tcx.mk_nil()) } hir::ExprMatch(ref discrim, ref arms, match_src) => {