2014-07-27 07:50:46 -04:00
|
|
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
2012-12-03 16:48:01 -08:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
2014-11-06 00:05:53 -08:00
|
|
|
use self::Context::*;
|
2012-12-03 16:48:01 -08:00
|
|
|
|
2016-01-21 10:52:37 +01:00
|
|
|
use rustc::session::Session;
|
2012-12-23 17:41:37 -05:00
|
|
|
|
2016-01-29 15:04:07 -05:00
|
|
|
use rustc::dep_graph::DepNode;
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
use rustc::hir::def::{Def, DefMap};
|
2016-03-29 08:50:44 +03:00
|
|
|
use rustc::hir::map::Map;
|
|
|
|
use rustc::hir::intravisit::{self, Visitor};
|
|
|
|
use rustc::hir;
|
2016-06-21 18:08:13 -04:00
|
|
|
use syntax_pos::Span;
|
2012-03-26 12:54:06 +02:00
|
|
|
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
#[derive(Clone, Copy, PartialEq)]
|
|
|
|
enum LoopKind {
|
|
|
|
Loop(hir::LoopSource),
|
|
|
|
WhileLoop,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl LoopKind {
|
|
|
|
fn name(self) -> &'static str {
|
|
|
|
match self {
|
|
|
|
LoopKind::Loop(hir::LoopSource::Loop) => "loop",
|
|
|
|
LoopKind::Loop(hir::LoopSource::WhileLet) => "while let",
|
|
|
|
LoopKind::Loop(hir::LoopSource::ForLoop) => "for",
|
|
|
|
LoopKind::WhileLoop => "while",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-03 22:54:18 -05:00
|
|
|
#[derive(Clone, Copy, PartialEq)]
|
2013-11-11 11:29:15 -08:00
|
|
|
enum Context {
|
2016-07-21 07:01:14 +05:30
|
|
|
Normal,
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
Loop(LoopKind),
|
2016-07-21 07:01:14 +05:30
|
|
|
Closure,
|
2013-02-19 02:40:42 -05:00
|
|
|
}
|
2012-03-26 12:54:06 +02:00
|
|
|
|
2015-03-30 09:38:44 -04:00
|
|
|
#[derive(Copy, Clone)]
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
struct CheckLoopVisitor<'a, 'ast: 'a> {
|
2014-04-05 10:05:31 +11:00
|
|
|
sess: &'a Session,
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
def_map: &'a DefMap,
|
|
|
|
hir_map: &'a Map<'ast>,
|
2016-07-21 07:01:14 +05:30
|
|
|
cx: Context,
|
2013-08-13 02:49:30 +02:00
|
|
|
}
|
|
|
|
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
pub fn check_crate(sess: &Session, def_map: &DefMap, map: &Map) {
|
2016-01-29 15:04:07 -05:00
|
|
|
let _task = map.dep_graph.in_task(DepNode::CheckLoops);
|
|
|
|
let krate = map.krate();
|
2016-11-02 18:22:59 -04:00
|
|
|
krate.visit_all_item_likes(&mut CheckLoopVisitor {
|
2016-07-21 07:01:14 +05:30
|
|
|
sess: sess,
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
def_map: def_map,
|
|
|
|
hir_map: map,
|
2016-07-21 07:01:14 +05:30
|
|
|
cx: Normal,
|
2016-11-02 18:22:59 -04:00
|
|
|
}.as_deep_visitor());
|
2013-08-13 02:49:30 +02:00
|
|
|
}
|
|
|
|
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
impl<'a, 'ast, 'v> Visitor<'v> for CheckLoopVisitor<'a, 'ast> {
|
2015-07-31 00:04:06 -07:00
|
|
|
fn visit_item(&mut self, i: &hir::Item) {
|
2015-11-17 17:51:44 -05:00
|
|
|
self.with_context(Normal, |v| intravisit::walk_item(v, i));
|
2013-08-13 02:49:30 +02:00
|
|
|
}
|
|
|
|
|
2016-11-04 18:20:15 -04:00
|
|
|
fn visit_impl_item(&mut self, i: &hir::ImplItem) {
|
|
|
|
self.with_context(Normal, |v| intravisit::walk_impl_item(v, i));
|
|
|
|
}
|
|
|
|
|
2015-07-31 00:04:06 -07:00
|
|
|
fn visit_expr(&mut self, e: &hir::Expr) {
|
2013-11-11 11:29:15 -08:00
|
|
|
match e.node {
|
2015-07-31 00:04:06 -07:00
|
|
|
hir::ExprWhile(ref e, ref b, _) => {
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
self.with_context(Loop(LoopKind::WhileLoop), |v| {
|
|
|
|
v.visit_expr(&e);
|
|
|
|
v.visit_block(&b);
|
|
|
|
});
|
2013-11-11 11:29:15 -08:00
|
|
|
}
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
hir::ExprLoop(ref b, _, source) => {
|
|
|
|
self.with_context(Loop(LoopKind::Loop(source)), |v| v.visit_block(&b));
|
2014-07-21 20:54:28 -07:00
|
|
|
}
|
2016-08-26 19:23:42 +03:00
|
|
|
hir::ExprClosure(.., ref b, _) => {
|
2016-10-26 02:27:14 +03:00
|
|
|
self.with_context(Closure, |v| v.visit_expr(&b));
|
2013-11-11 11:29:15 -08:00
|
|
|
}
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
hir::ExprBreak(ref opt_label, ref opt_expr) => {
|
|
|
|
if opt_expr.is_some() {
|
|
|
|
let loop_kind = if opt_label.is_some() {
|
|
|
|
let loop_def = self.def_map.get(&e.id).unwrap().full_def();
|
|
|
|
if loop_def == Def::Err {
|
|
|
|
None
|
|
|
|
} else if let Def::Label(loop_id) = loop_def {
|
|
|
|
Some(match self.hir_map.expect_expr(loop_id).node {
|
|
|
|
hir::ExprWhile(..) => LoopKind::WhileLoop,
|
|
|
|
hir::ExprLoop(_, _, source) => LoopKind::Loop(source),
|
|
|
|
ref r => span_bug!(e.span,
|
|
|
|
"break label resolved to a non-loop: {:?}", r),
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
span_bug!(e.span, "break resolved to a non-label")
|
|
|
|
}
|
|
|
|
} else if let Loop(kind) = self.cx {
|
|
|
|
Some(kind)
|
|
|
|
} else {
|
|
|
|
// `break` outside a loop - caught below
|
|
|
|
None
|
|
|
|
};
|
|
|
|
match loop_kind {
|
|
|
|
None | Some(LoopKind::Loop(hir::LoopSource::Loop)) => (),
|
|
|
|
Some(kind) => {
|
|
|
|
struct_span_err!(self.sess, e.span, E0571,
|
|
|
|
"`break` with value from a `{}` loop",
|
|
|
|
kind.name())
|
|
|
|
.span_label(e.span,
|
|
|
|
&format!("can only break with a value inside `loop`"))
|
|
|
|
.emit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.require_loop("break", e.span);
|
|
|
|
}
|
2015-07-31 00:04:06 -07:00
|
|
|
hir::ExprAgain(_) => self.require_loop("continue", e.span),
|
2016-07-21 07:01:14 +05:30
|
|
|
_ => intravisit::walk_expr(self, e),
|
2013-11-11 11:29:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-13 02:49:30 +02:00
|
|
|
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
impl<'a, 'ast> CheckLoopVisitor<'a, 'ast> {
|
2016-07-21 07:01:14 +05:30
|
|
|
fn with_context<F>(&mut self, cx: Context, f: F)
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
where F: FnOnce(&mut CheckLoopVisitor<'a, 'ast>)
|
2014-12-08 20:26:43 -05:00
|
|
|
{
|
2014-09-12 13:10:30 +03:00
|
|
|
let old_cx = self.cx;
|
|
|
|
self.cx = cx;
|
|
|
|
f(self);
|
|
|
|
self.cx = old_cx;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn require_loop(&self, name: &str, span: Span) {
|
|
|
|
match self.cx {
|
Implement the `loop_break_value` feature.
This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
currently deduced type of that loop, the desired type, and a list of
break expressions currently seen. `loop` loops get a fresh type
variable as their initial type (this logic is stolen from that for
arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
`expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
termination of the loop; rather, the `break` expression assigns the
result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
blocks. That is, `while break { break-value } { while-body }` is
illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
of a `while` loop illegal, just in case we wanted to do anything with
that design space in the future.
This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-10-29 15:15:06 -07:00
|
|
|
Loop(_) => {}
|
2013-11-11 11:29:15 -08:00
|
|
|
Closure => {
|
2016-08-08 00:12:53 +05:30
|
|
|
struct_span_err!(self.sess, span, E0267, "`{}` inside of a closure", name)
|
|
|
|
.span_label(span, &format!("cannot break inside of a closure"))
|
|
|
|
.emit();
|
2013-11-11 11:29:15 -08:00
|
|
|
}
|
|
|
|
Normal => {
|
2016-08-08 00:12:53 +05:30
|
|
|
struct_span_err!(self.sess, span, E0268, "`{}` outside of loop", name)
|
|
|
|
.span_label(span, &format!("cannot break outside of a loop"))
|
|
|
|
.emit();
|
2013-11-11 11:29:15 -08:00
|
|
|
}
|
|
|
|
}
|
2013-08-13 02:49:30 +02:00
|
|
|
}
|
2012-07-14 01:24:07 +10:00
|
|
|
}
|