rust/src/test/run-pass/issue-25343.rs
Georg Brandl 6fed0132f3 middle: reset loop labels while visiting closure
This should fix #31754 and follow-up #25343.  Before the latter, the
closure was visited twice in the context of the enclosing fn, which
made even a single closure with a loop label emit a warning.

With this change, the closure is still visited within the context
of the main fn (which is intended, since it is not a separate item)
but resets the found loop labels while being visited.

Fixes: #31754
2016-05-02 16:48:36 +02:00

32 lines
739 B
Rust

// Copyright 2015 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.
#[allow(unused)]
fn main() {
|| {
'label: loop {
}
};
// More cases added from issue 31754
'label2: loop {
break;
}
let closure = || {
'label2: loop {}
};
fn inner_fn() {
'label2: loop {}
}
}