2019-02-08 11:40:49 +00:00
|
|
|
use Context::*;
|
2012-12-04 00:48:01 +00:00
|
|
|
|
2020-01-09 10:18:47 +00:00
|
|
|
use rustc_errors::{struct_span_err, Applicability};
|
2020-01-05 01:37:57 +00:00
|
|
|
use rustc_hir as hir;
|
2020-06-27 11:09:54 +00:00
|
|
|
use rustc_hir::def_id::LocalDefId;
|
2021-11-03 23:03:12 +00:00
|
|
|
use rustc_hir::intravisit::{self, Visitor};
|
2020-01-05 01:37:57 +00:00
|
|
|
use rustc_hir::{Destination, Movability, Node};
|
2020-03-29 15:19:48 +00:00
|
|
|
use rustc_middle::hir::map::Map;
|
2021-11-03 23:03:12 +00:00
|
|
|
use rustc_middle::hir::nested_filter;
|
2020-03-29 15:19:48 +00:00
|
|
|
use rustc_middle::ty::query::Providers;
|
|
|
|
use rustc_middle::ty::TyCtxt;
|
2020-01-18 20:53:53 +00:00
|
|
|
use rustc_session::Session;
|
2020-05-25 15:15:26 +00:00
|
|
|
use rustc_span::hygiene::DesugaringKind;
|
2019-12-31 17:15:40 +00:00
|
|
|
use rustc_span::Span;
|
2012-03-26 10:54:06 +00:00
|
|
|
|
2018-07-01 22:40:03 +00:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
2013-11-11 19:29:15 +00:00
|
|
|
enum Context {
|
2016-07-21 01:31:14 +00:00
|
|
|
Normal,
|
2019-06-19 15:21:28 +00:00
|
|
|
Loop(hir::LoopSource),
|
2019-08-21 10:17:59 +00:00
|
|
|
Closure(Span),
|
|
|
|
AsyncClosure(Span),
|
2018-04-25 17:28:04 +00:00
|
|
|
LabeledBlock,
|
2018-07-01 16:24:07 +00:00
|
|
|
AnonConst,
|
2013-02-19 07:40:42 +00:00
|
|
|
}
|
2012-03-26 10:54:06 +00:00
|
|
|
|
2015-03-30 13:38:44 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2019-06-14 16:39:39 +00:00
|
|
|
struct CheckLoopVisitor<'a, 'hir> {
|
2014-04-04 23:05:31 +00:00
|
|
|
sess: &'a Session,
|
2020-02-09 14:32:00 +00:00
|
|
|
hir_map: Map<'hir>,
|
2016-07-21 01:31:14 +00:00
|
|
|
cx: Context,
|
2013-08-13 00:49:30 +00:00
|
|
|
}
|
|
|
|
|
2020-06-27 11:09:54 +00:00
|
|
|
fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
2022-05-07 20:35:38 +00:00
|
|
|
tcx.hir().deep_visit_item_likes_in_module(
|
2019-01-11 03:58:46 +00:00
|
|
|
module_def_id,
|
2022-05-07 19:43:10 +00:00
|
|
|
&mut CheckLoopVisitor { sess: &tcx.sess, hir_map: tcx.hir(), cx: Normal },
|
2016-11-02 22:22:59 +00:00
|
|
|
);
|
2013-08-13 00:49:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-05 20:00:14 +00:00
|
|
|
pub(crate) fn provide(providers: &mut Providers) {
|
2018-06-06 20:13:52 +00:00
|
|
|
*providers = Providers { check_mod_loops, ..*providers };
|
|
|
|
}
|
|
|
|
|
2017-01-26 01:21:50 +00:00
|
|
|
impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
2021-11-03 23:03:12 +00:00
|
|
|
type NestedFilter = nested_filter::OnlyBodies;
|
2020-01-07 16:25:33 +00:00
|
|
|
|
2021-11-03 23:03:12 +00:00
|
|
|
fn nested_visit_map(&mut self) -> Self::Map {
|
|
|
|
self.hir_map
|
2016-10-29 13:01:11 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 16:24:07 +00:00
|
|
|
fn visit_anon_const(&mut self, c: &'hir hir::AnonConst) {
|
|
|
|
self.with_context(AnonConst, |v| intravisit::walk_anon_const(v, c));
|
|
|
|
}
|
|
|
|
|
2019-11-30 14:08:22 +00:00
|
|
|
fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
|
2019-09-26 13:39:48 +00:00
|
|
|
match e.kind {
|
2021-01-21 01:15:08 +00:00
|
|
|
hir::ExprKind::Loop(ref b, _, source, _) => {
|
2019-06-19 15:21:28 +00:00
|
|
|
self.with_context(Loop(source), |v| v.visit_block(&b));
|
2014-07-22 03:54:28 +00:00
|
|
|
}
|
2019-08-21 10:17:59 +00:00
|
|
|
hir::ExprKind::Closure(_, ref function_decl, b, span, movability) => {
|
2019-11-09 17:06:57 +00:00
|
|
|
let cx = if let Some(Movability::Static) = movability {
|
2019-08-21 10:17:59 +00:00
|
|
|
AsyncClosure(span)
|
2019-08-17 11:17:02 +00:00
|
|
|
} else {
|
2019-08-21 10:17:59 +00:00
|
|
|
Closure(span)
|
2019-08-17 11:17:02 +00:00
|
|
|
};
|
2018-05-17 21:50:27 +00:00
|
|
|
self.visit_fn_decl(&function_decl);
|
2019-08-17 11:17:02 +00:00
|
|
|
self.with_context(cx, |v| v.visit_nested_body(b));
|
2013-11-11 19:29:15 +00:00
|
|
|
}
|
2018-07-11 12:05:29 +00:00
|
|
|
hir::ExprKind::Block(ref b, Some(_label)) => {
|
2018-04-25 17:28:04 +00:00
|
|
|
self.with_context(LabeledBlock, |v| v.visit_block(&b));
|
|
|
|
}
|
2021-01-22 02:13:05 +00:00
|
|
|
hir::ExprKind::Break(break_label, ref opt_expr) => {
|
2020-04-24 20:58:41 +00:00
|
|
|
if let Some(e) = opt_expr {
|
|
|
|
self.visit_expr(e);
|
|
|
|
}
|
2018-05-17 11:12:05 +00:00
|
|
|
|
2021-01-22 02:13:05 +00:00
|
|
|
if self.require_label_in_labeled_block(e.span, &break_label, "break") {
|
2018-05-16 07:18:26 +00:00
|
|
|
// If we emitted an error about an unlabeled break in a labeled
|
|
|
|
// block, we don't need any further checking for this break any more
|
|
|
|
return;
|
|
|
|
}
|
2018-05-12 09:09:36 +00:00
|
|
|
|
2021-01-22 02:13:05 +00:00
|
|
|
let loop_id = match break_label.target_id {
|
2020-04-12 18:20:07 +00:00
|
|
|
Ok(loop_id) => Some(loop_id),
|
|
|
|
Err(hir::LoopIdError::OutsideLoopScope) => None,
|
2018-05-11 13:00:09 +00:00
|
|
|
Err(hir::LoopIdError::UnlabeledCfInWhileCondition) => {
|
|
|
|
self.emit_unlabled_cf_in_while_condition(e.span, "break");
|
2020-04-12 18:20:07 +00:00
|
|
|
None
|
2018-05-11 13:00:09 +00:00
|
|
|
}
|
2020-04-12 18:20:07 +00:00
|
|
|
Err(hir::LoopIdError::UnresolvedLabel) => None,
|
2017-02-16 07:28:59 +00:00
|
|
|
};
|
2018-04-25 17:28:04 +00:00
|
|
|
|
2021-01-21 01:15:08 +00:00
|
|
|
if let Some(Node::Block(_)) = loop_id.and_then(|id| self.hir_map.find(id)) {
|
2021-01-21 01:25:27 +00:00
|
|
|
return;
|
2018-05-11 13:00:09 +00:00
|
|
|
}
|
2017-02-16 07:28:59 +00:00
|
|
|
|
2021-01-21 01:25:27 +00:00
|
|
|
if let Some(break_expr) = opt_expr {
|
2021-01-22 02:13:05 +00:00
|
|
|
let (head, loop_label, loop_kind) = if let Some(loop_id) = loop_id {
|
2021-01-21 01:25:27 +00:00
|
|
|
match self.hir_map.expect_expr(loop_id).kind {
|
|
|
|
hir::ExprKind::Loop(_, label, source, sp) => {
|
|
|
|
(Some(sp), label, Some(source))
|
|
|
|
}
|
2017-02-15 22:52:27 +00:00
|
|
|
ref r => {
|
|
|
|
span_bug!(e.span, "break label resolved to a non-loop: {:?}", r)
|
2019-12-22 22:42:04 +00:00
|
|
|
}
|
2021-01-21 01:25:27 +00:00
|
|
|
}
|
2020-04-12 18:20:07 +00:00
|
|
|
} else {
|
2021-01-21 01:25:27 +00:00
|
|
|
(None, None, None)
|
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 22:15:06 +00:00
|
|
|
};
|
|
|
|
match loop_kind {
|
2019-06-19 15:21:28 +00:00
|
|
|
None | Some(hir::LoopSource::Loop) => (),
|
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 22:15:06 +00:00
|
|
|
Some(kind) => {
|
2021-01-21 01:25:27 +00:00
|
|
|
let mut err = struct_span_err!(
|
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 22:15:06 +00:00
|
|
|
self.sess,
|
|
|
|
e.span,
|
|
|
|
E0571,
|
|
|
|
"`break` with value from a `{}` loop",
|
|
|
|
kind.name()
|
2021-01-21 01:25:27 +00:00
|
|
|
);
|
|
|
|
err.span_label(
|
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 22:15:06 +00:00
|
|
|
e.span,
|
2021-01-21 01:25:27 +00:00
|
|
|
"can only break with a value inside `loop` or breakable block",
|
|
|
|
);
|
|
|
|
if let Some(head) = head {
|
|
|
|
err.span_label(
|
|
|
|
head,
|
|
|
|
&format!(
|
|
|
|
"you can't `break` with a value in a `{}` loop",
|
|
|
|
kind.name()
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
err.span_suggestion(
|
2018-09-17 17:13:08 +00:00
|
|
|
e.span,
|
|
|
|
&format!(
|
2021-01-21 01:25:27 +00:00
|
|
|
"use `break` on its own without a value inside this `{}` loop",
|
|
|
|
kind.name(),
|
2018-09-17 17:13:08 +00:00
|
|
|
),
|
2021-01-22 02:13:05 +00:00
|
|
|
format!(
|
|
|
|
"break{}",
|
|
|
|
break_label
|
|
|
|
.label
|
|
|
|
.map_or_else(String::new, |l| format!(" {}", l.ident))
|
|
|
|
),
|
2018-09-17 17:13:08 +00:00
|
|
|
Applicability::MaybeIncorrect,
|
2021-01-21 01:25:27 +00:00
|
|
|
);
|
2021-01-22 02:13:05 +00:00
|
|
|
if let (Some(label), None) = (loop_label, break_label.label) {
|
2021-01-21 01:25:27 +00:00
|
|
|
match break_expr.kind {
|
|
|
|
hir::ExprKind::Path(hir::QPath::Resolved(
|
|
|
|
None,
|
|
|
|
hir::Path {
|
|
|
|
segments: [segment],
|
|
|
|
res: hir::def::Res::Err,
|
|
|
|
..
|
|
|
|
},
|
|
|
|
)) if label.ident.to_string()
|
|
|
|
== format!("'{}", segment.ident) =>
|
|
|
|
{
|
|
|
|
// This error is redundant, we will have already emitted a
|
|
|
|
// suggestion to use the label when `segment` wasn't found
|
|
|
|
// (hence the `Res::Err` check).
|
|
|
|
err.delay_as_bug();
|
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
err.span_suggestion(
|
|
|
|
break_expr.span,
|
|
|
|
"alternatively, you might have meant to use the \
|
|
|
|
available loop label",
|
|
|
|
label.ident.to_string(),
|
|
|
|
Applicability::MaybeIncorrect,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err.emit();
|
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 22:15:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-02-16 07:28:59 +00:00
|
|
|
|
2018-04-25 17:28:04 +00:00
|
|
|
self.require_break_cx("break", e.span);
|
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 22:15:06 +00:00
|
|
|
}
|
2018-09-07 13:10:16 +00:00
|
|
|
hir::ExprKind::Continue(destination) => {
|
|
|
|
self.require_label_in_labeled_block(e.span, &destination, "continue");
|
2018-05-12 09:09:36 +00:00
|
|
|
|
2018-09-07 13:10:16 +00:00
|
|
|
match destination.target_id {
|
2018-05-12 08:18:21 +00:00
|
|
|
Ok(loop_id) => {
|
2019-06-24 07:58:49 +00:00
|
|
|
if let Node::Block(block) = self.hir_map.find(loop_id).unwrap() {
|
2018-05-12 08:18:21 +00:00
|
|
|
struct_span_err!(
|
|
|
|
self.sess,
|
|
|
|
e.span,
|
|
|
|
E0696,
|
|
|
|
"`continue` pointing to a labeled block"
|
|
|
|
)
|
|
|
|
.span_label(e.span, "labeled blocks cannot be `continue`'d")
|
2019-11-25 20:35:30 +00:00
|
|
|
.span_label(block.span, "labeled block the `continue` points to")
|
2018-05-12 08:18:21 +00:00
|
|
|
.emit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(hir::LoopIdError::UnlabeledCfInWhileCondition) => {
|
|
|
|
self.emit_unlabled_cf_in_while_condition(e.span, "continue");
|
|
|
|
}
|
2018-09-07 13:10:16 +00:00
|
|
|
Err(_) => {}
|
2017-02-16 07:28:59 +00:00
|
|
|
}
|
2018-04-25 17:28:04 +00:00
|
|
|
self.require_break_cx("continue", e.span)
|
2017-02-16 07:28:59 +00:00
|
|
|
}
|
2016-07-21 01:31:14 +00:00
|
|
|
_ => intravisit::walk_expr(self, e),
|
2013-11-11 19:29:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-13 00:49:30 +00:00
|
|
|
|
2017-01-26 01:21:50 +00:00
|
|
|
impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> {
|
2016-07-21 01:31:14 +00:00
|
|
|
fn with_context<F>(&mut self, cx: Context, f: F)
|
2017-01-26 01:21:50 +00:00
|
|
|
where
|
|
|
|
F: FnOnce(&mut CheckLoopVisitor<'a, 'hir>),
|
2014-12-09 01:26:43 +00:00
|
|
|
{
|
2014-09-12 10:10:30 +00:00
|
|
|
let old_cx = self.cx;
|
|
|
|
self.cx = cx;
|
|
|
|
f(self);
|
|
|
|
self.cx = old_cx;
|
|
|
|
}
|
|
|
|
|
2018-04-25 17:28:04 +00:00
|
|
|
fn require_break_cx(&self, name: &str, span: Span) {
|
2019-08-21 11:32:38 +00:00
|
|
|
let err_inside_of = |article, ty, closure_span| {
|
|
|
|
struct_span_err!(self.sess, span, E0267, "`{}` inside of {} {}", name, article, ty)
|
|
|
|
.span_label(span, format!("cannot `{}` inside of {} {}", name, article, ty))
|
|
|
|
.span_label(closure_span, &format!("enclosing {}", ty))
|
2016-08-07 18:42:53 +00:00
|
|
|
.emit();
|
2019-08-21 10:17:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
match self.cx {
|
|
|
|
LabeledBlock | Loop(_) => {}
|
|
|
|
Closure(closure_span) => err_inside_of("a", "closure", closure_span),
|
|
|
|
AsyncClosure(closure_span) => err_inside_of("an", "`async` block", closure_span),
|
2018-07-01 16:24:07 +00:00
|
|
|
Normal | AnonConst => {
|
2019-08-21 10:17:59 +00:00
|
|
|
struct_span_err!(self.sess, span, E0268, "`{}` outside of a loop", name)
|
|
|
|
.span_label(span, format!("cannot `{}` outside of a loop", name))
|
2016-08-07 18:42:53 +00:00
|
|
|
.emit();
|
2019-08-21 10:17:59 +00:00
|
|
|
}
|
2013-11-11 19:29:15 +00:00
|
|
|
}
|
2013-08-13 00:49:30 +00:00
|
|
|
}
|
2017-02-16 07:28:59 +00:00
|
|
|
|
2018-05-16 07:18:26 +00:00
|
|
|
fn require_label_in_labeled_block(
|
|
|
|
&mut self,
|
|
|
|
span: Span,
|
|
|
|
label: &Destination,
|
|
|
|
cf_type: &str,
|
|
|
|
) -> bool {
|
2020-05-25 15:15:26 +00:00
|
|
|
if !span.is_desugaring(DesugaringKind::QuestionMark) && self.cx == LabeledBlock {
|
2018-05-12 09:09:36 +00:00
|
|
|
if label.label.is_none() {
|
|
|
|
struct_span_err!(
|
|
|
|
self.sess,
|
|
|
|
span,
|
|
|
|
E0695,
|
|
|
|
"unlabeled `{}` inside of a labeled block",
|
|
|
|
cf_type
|
|
|
|
)
|
|
|
|
.span_label(
|
|
|
|
span,
|
|
|
|
format!(
|
|
|
|
"`{}` statements that would diverge to or through \
|
|
|
|
a labeled block need to bear a label",
|
|
|
|
cf_type
|
2019-12-22 22:42:04 +00:00
|
|
|
),
|
2018-05-12 09:09:36 +00:00
|
|
|
)
|
|
|
|
.emit();
|
2018-05-16 07:18:26 +00:00
|
|
|
return true;
|
2018-05-12 09:09:36 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-20 14:03:11 +00:00
|
|
|
false
|
2018-05-12 09:09:36 +00:00
|
|
|
}
|
2017-02-16 07:28:59 +00:00
|
|
|
fn emit_unlabled_cf_in_while_condition(&mut self, span: Span, cf_type: &str) {
|
2017-02-23 02:10:37 +00:00
|
|
|
struct_span_err!(
|
|
|
|
self.sess,
|
|
|
|
span,
|
|
|
|
E0590,
|
2017-02-16 07:28:59 +00:00
|
|
|
"`break` or `continue` with no label in the condition of a `while` loop"
|
|
|
|
)
|
2017-05-04 12:17:23 +00:00
|
|
|
.span_label(span, format!("unlabeled `{}` in the condition of a `while` loop", cf_type))
|
2017-02-16 07:28:59 +00:00
|
|
|
.emit();
|
|
|
|
}
|
2012-07-13 15:24:07 +00:00
|
|
|
}
|