@@ -55,7 +55,7 @@ use rustc::util::nodemap::{NodeMap, NodeSet, FnvHashMap, FnvHashSet};
55
55
56
56
use syntax:: ext:: hygiene:: { Mark , SyntaxContext } ;
57
57
use syntax:: ast:: { self , FloatTy } ;
58
- use syntax:: ast:: { CRATE_NODE_ID , Name , NodeId , Ident , IntTy , UintTy } ;
58
+ use syntax:: ast:: { CRATE_NODE_ID , Name , NodeId , Ident , SpannedIdent , IntTy , UintTy } ;
59
59
use syntax:: ext:: base:: SyntaxExtension ;
60
60
use syntax:: parse:: token:: { self , keywords} ;
61
61
use syntax:: util:: lev_distance:: find_best_match_for_name;
@@ -2278,7 +2278,7 @@ impl<'a> Resolver<'a> {
2278
2278
}
2279
2279
2280
2280
fn fresh_binding ( & mut self ,
2281
- ident : & ast :: SpannedIdent ,
2281
+ ident : & SpannedIdent ,
2282
2282
pat_id : NodeId ,
2283
2283
outer_pat_id : NodeId ,
2284
2284
pat_src : PatternSource ,
@@ -2842,11 +2842,11 @@ impl<'a> Resolver<'a> {
2842
2842
} SuggestionType :: NotFound
2843
2843
}
2844
2844
2845
- fn resolve_labeled_block ( & mut self , label : Option < Ident > , id : NodeId , block : & Block ) {
2845
+ fn resolve_labeled_block ( & mut self , label : Option < SpannedIdent > , id : NodeId , block : & Block ) {
2846
2846
if let Some ( label) = label {
2847
2847
let def = Def :: Label ( id) ;
2848
2848
self . with_label_rib ( |this| {
2849
- this. label_ribs . last_mut ( ) . unwrap ( ) . bindings . insert ( label, def) ;
2849
+ this. label_ribs . last_mut ( ) . unwrap ( ) . bindings . insert ( label. node , def) ;
2850
2850
this. visit_block ( block) ;
2851
2851
} ) ;
2852
2852
} else {
@@ -3039,19 +3039,6 @@ impl<'a> Resolver<'a> {
3039
3039
visit:: walk_expr ( self , expr) ;
3040
3040
}
3041
3041
3042
- ExprKind :: Loop ( _, Some ( label) ) | ExprKind :: While ( .., Some ( label) ) => {
3043
- self . with_label_rib ( |this| {
3044
- let def = Def :: Label ( expr. id ) ;
3045
-
3046
- {
3047
- let rib = this. label_ribs . last_mut ( ) . unwrap ( ) ;
3048
- rib. bindings . insert ( label. node , def) ;
3049
- }
3050
-
3051
- visit:: walk_expr ( this, expr) ;
3052
- } )
3053
- }
3054
-
3055
3042
ExprKind :: Break ( Some ( label) ) | ExprKind :: Continue ( Some ( label) ) => {
3056
3043
match self . search_label ( label. node ) {
3057
3044
None => {
@@ -3081,12 +3068,19 @@ impl<'a> Resolver<'a> {
3081
3068
optional_else. as_ref ( ) . map ( |expr| self . visit_expr ( expr) ) ;
3082
3069
}
3083
3070
3071
+ ExprKind :: Loop ( ref block, label) => self . resolve_labeled_block ( label, expr. id , & block) ,
3072
+
3073
+ ExprKind :: While ( ref subexpression, ref block, label) => {
3074
+ self . visit_expr ( subexpression) ;
3075
+ self . resolve_labeled_block ( label, expr. id , & block) ;
3076
+ }
3077
+
3084
3078
ExprKind :: WhileLet ( ref pattern, ref subexpression, ref block, label) => {
3085
3079
self . visit_expr ( subexpression) ;
3086
3080
self . value_ribs . push ( Rib :: new ( NormalRibKind ) ) ;
3087
3081
self . resolve_pattern ( pattern, PatternSource :: WhileLet , & mut FnvHashMap ( ) ) ;
3088
3082
3089
- self . resolve_labeled_block ( label. map ( |l| l . node ) , expr. id , block) ;
3083
+ self . resolve_labeled_block ( label, expr. id , block) ;
3090
3084
3091
3085
self . value_ribs . pop ( ) ;
3092
3086
}
@@ -3096,7 +3090,7 @@ impl<'a> Resolver<'a> {
3096
3090
self . value_ribs . push ( Rib :: new ( NormalRibKind ) ) ;
3097
3091
self . resolve_pattern ( pattern, PatternSource :: For , & mut FnvHashMap ( ) ) ;
3098
3092
3099
- self . resolve_labeled_block ( label. map ( |l| l . node ) , expr. id , block) ;
3093
+ self . resolve_labeled_block ( label, expr. id , block) ;
3100
3094
3101
3095
self . value_ribs . pop ( ) ;
3102
3096
}
0 commit comments