Obsolete parsing 'loop' as 'continue'
This commit is contained in:
parent
7f9b918562
commit
4af849bc12
@ -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);
|
||||
|
@ -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);
|
||||
|
15
src/test/compile-fail/loop-as-continue.rs
Normal file
15
src/test/compile-fail/loop-as-continue.rs
Normal file
@ -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`
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user