提交 9449161a 编写于 作者: S Seo Sanghyeon

Do not resolve labels across function boundary

上级 5ba61026
......@@ -3934,6 +3934,30 @@ fn search_ribs(&self,
None
}
fn search_label(&self, name: Name) -> Option<DefLike> {
for rib in self.label_ribs.iter().rev() {
match rib.kind {
NormalRibKind => {
// Continue
}
_ => {
// Do not resolve labels across function boundary
return None
}
}
let result = rib.bindings.get(&name).cloned();
match result {
Some(_) => {
return result
}
None => {
// Continue
}
}
}
None
}
fn resolve_crate(&mut self, krate: &ast::Crate) {
debug!("(resolving crate) starting");
......@@ -5752,8 +5776,7 @@ fn resolve_expr(&mut self, expr: &Expr) {
ExprBreak(Some(label)) | ExprAgain(Some(label)) => {
let renamed = mtwt::resolve(label);
match self.search_ribs(self.label_ribs[],
renamed, expr.span) {
match self.search_label(renamed) {
None => {
self.resolve_error(
expr.span,
......
// Copyright 2014 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 f() {
'l: loop {
fn g() {
loop {
break 'l; //~ ERROR use of undeclared label
}
}
}
}
fn main() {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册