Skip to content

Commit 4af849b

Browse files
committed
Obsolete parsing 'loop' as 'continue'
1 parent 7f9b918 commit 4af849b

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/libsyntax/parse/obsolete.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub enum ObsoleteSyntax {
6363
ObsoleteTraitFuncVisibility,
6464
ObsoleteConstPointer,
6565
ObsoleteEmptyImpl,
66+
ObsoleteLoopAsContinue,
6667
}
6768

6869
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -244,6 +245,11 @@ impl ParserObsoleteMethods for Parser {
244245
"empty implementation",
245246
"instead of `impl A;`, write `impl A {}`"
246247
),
248+
ObsoleteLoopAsContinue => (
249+
"`loop` instead of `continue`",
250+
"`loop` is now only used for loops and `continue` is used for \
251+
skipping iterations"
252+
),
247253
};
248254

249255
self.report(sp, kind, kind_str, desc);

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,6 +2597,7 @@ impl Parser {
25972597
"a label may not be used with a `loop` expression");
25982598
}
25992599

2600+
self.obsolete(*self.last_span, ObsoleteLoopAsContinue);
26002601
let lo = self.span.lo;
26012602
let ex = if self.token_is_lifetime(&*self.token) {
26022603
let lifetime = self.get_lifetime(&*self.token);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
loop {
13+
loop //~ ERROR: `loop` instead of `continue`
14+
}
15+
}

0 commit comments

Comments
 (0)