File tree Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -3934,6 +3934,30 @@ impl<'a> Resolver<'a> {
3934
3934
None
3935
3935
}
3936
3936
3937
+ fn search_label ( & self , name : Name ) -> Option < DefLike > {
3938
+ for rib in self . label_ribs . iter ( ) . rev ( ) {
3939
+ match rib. kind {
3940
+ NormalRibKind => {
3941
+ // Continue
3942
+ }
3943
+ _ => {
3944
+ // Do not resolve labels across function boundary
3945
+ return None
3946
+ }
3947
+ }
3948
+ let result = rib. bindings . get ( & name) . cloned ( ) ;
3949
+ match result {
3950
+ Some ( _) => {
3951
+ return result
3952
+ }
3953
+ None => {
3954
+ // Continue
3955
+ }
3956
+ }
3957
+ }
3958
+ None
3959
+ }
3960
+
3937
3961
fn resolve_crate ( & mut self , krate : & ast:: Crate ) {
3938
3962
debug ! ( "(resolving crate) starting" ) ;
3939
3963
@@ -5752,8 +5776,7 @@ impl<'a> Resolver<'a> {
5752
5776
5753
5777
ExprBreak ( Some ( label) ) | ExprAgain ( Some ( label) ) => {
5754
5778
let renamed = mtwt:: resolve ( label) ;
5755
- match self . search_ribs ( self . label_ribs [ ] ,
5756
- renamed, expr. span ) {
5779
+ match self . search_label ( renamed) {
5757
5780
None => {
5758
5781
self . resolve_error (
5759
5782
expr. span ,
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 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 f ( ) {
12
+ ' l: loop {
13
+ fn g ( ) {
14
+ loop {
15
+ break ' l; //~ ERROR use of undeclared label
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments