Add diagnostic for break outside of loop

This commit is contained in:
Florian Diebold 2020-05-08 19:48:03 +02:00
parent f8bf94a4b9
commit d0129c4ddb
4 changed files with 62 additions and 1 deletions

View file

@ -235,6 +235,10 @@ impl<'a> InferenceContext<'a> {
}
if let Some(ctxt) = self.breakables.last_mut() {
ctxt.may_break = true;
} else {
self.push_diagnostic(InferenceDiagnostic::BreakOutsideOfLoop {
expr: tgt_expr,
});
}
Ty::simple(TypeCtor::Never)
}