diff options
| author | varkor <github@varkor.com> | 2018-07-01 23:40:03 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-07-02 19:44:27 +0100 |
| commit | 4d66b65850cba7302c79c031f9fa61e7162aca43 (patch) | |
| tree | 378244ae4325c54356d78a6e5716295f1626a38f /src | |
| parent | 90eee7dff21e6fa7be553cc3863aaeb8a73db442 (diff) | |
Fix issue-50585 test
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_passes/loops.rs | 4 | ||||
| -rw-r--r-- | 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) => { |
