about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libsyntax/parse/obsolete.rs6
-rw-r--r--src/libsyntax/parse/parser.rs1
-rw-r--r--src/test/compile-fail/loop-as-continue.rs15
3 files changed, 22 insertions, 0 deletions
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index adf0c208da4..5a8563f963d 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -63,6 +63,7 @@ pub enum ObsoleteSyntax {
     ObsoleteTraitFuncVisibility,
     ObsoleteConstPointer,
     ObsoleteEmptyImpl,
+    ObsoleteLoopAsContinue,
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -244,6 +245,11 @@ impl ParserObsoleteMethods for Parser {
                 "empty implementation",
                 "instead of `impl A;`, write `impl A {}`"
             ),
+            ObsoleteLoopAsContinue => (
+                "`loop` instead of `continue`",
+                "`loop` is now only used for loops and `continue` is used for \
+                 skipping iterations"
+            ),
         };
 
         self.report(sp, kind, kind_str, desc);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 4dd09cbcbd2..5c88c617950 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2597,6 +2597,7 @@ impl Parser {
                               "a label may not be used with a `loop` expression");
             }
 
+            self.obsolete(*self.last_span, ObsoleteLoopAsContinue);
             let lo = self.span.lo;
             let ex = if self.token_is_lifetime(&*self.token) {
                 let lifetime = self.get_lifetime(&*self.token);
diff --git a/src/test/compile-fail/loop-as-continue.rs b/src/test/compile-fail/loop-as-continue.rs
new file mode 100644
index 00000000000..e4273fdfeff
--- /dev/null
+++ b/src/test/compile-fail/loop-as-continue.rs
@@ -0,0 +1,15 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// 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.
+
+fn main() {
+    loop {
+        loop //~ ERROR: `loop` instead of `continue`
+    }
+}