Skip to content

Commit 4d66b65

Browse files
committed
Fix issue-50585 test
1 parent 90eee7d commit 4d66b65

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/librustc_passes/loops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc::hir::{self, Destination};
1717
use syntax::ast;
1818
use syntax_pos::Span;
1919

20-
#[derive(Clone, Copy, PartialEq)]
20+
#[derive(Clone, Copy, Debug, PartialEq)]
2121
enum LoopKind {
2222
Loop(hir::LoopSource),
2323
WhileLoop,
@@ -34,7 +34,7 @@ impl LoopKind {
3434
}
3535
}
3636

37-
#[derive(Clone, Copy, PartialEq)]
37+
#[derive(Clone, Copy, Debug, PartialEq)]
3838
enum Context {
3939
Normal,
4040
Loop(LoopKind),

src/librustc_typeck/check/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -3827,7 +3827,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
38273827
// this can only happen if the `break` was not
38283828
// inside a loop at all, which is caught by the
38293829
// loop-checking pass.
3830-
assert!(self.tcx.sess.err_count() > 0);
3830+
if self.tcx.sess.err_count() == 0 {
3831+
self.tcx.sess.delay_span_bug(expr.span,
3832+
"break was outside loop, but no error was emitted");
3833+
}
38313834

38323835
// We still need to assign a type to the inner expression to
38333836
// prevent the ICE in #43162.
@@ -3960,7 +3963,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
39603963
// is nil. This makes sense because infinite loops
39613964
// (which would have type !) are only possible iff we
39623965
// permit break with a value [1].
3963-
assert!(ctxt.coerce.is_some() || ctxt.may_break); // [1]
3966+
if ctxt.coerce.is_none() && !ctxt.may_break {
3967+
// [1]
3968+
self.tcx.sess.delay_span_bug(body.span, "no coercion, but loop may not break");
3969+
}
39643970
ctxt.coerce.map(|c| c.complete(self)).unwrap_or(self.tcx.mk_nil())
39653971
}
39663972
hir::ExprMatch(ref discrim, ref arms, match_src) => {

0 commit comments

Comments
 (0)