@@ -104,9 +104,14 @@ pub(super) fn lower_body(
104
104
{
105
105
let is_mutable =
106
106
self_param_syn. mut_token ( ) . is_some ( ) && self_param_syn. amp_token ( ) . is_none ( ) ;
107
+ let hygiene = self_param_syn
108
+ . name ( )
109
+ . map ( |name| collector. hygiene_id_for ( name. syntax ( ) . text_range ( ) ) )
110
+ . unwrap_or ( HygieneId :: ROOT ) ;
107
111
let binding_id: la_arena:: Idx < Binding > = collector. alloc_binding (
108
112
Name :: new_symbol_root ( sym:: self_) ,
109
113
BindingAnnotation :: new ( is_mutable, false ) ,
114
+ hygiene,
110
115
) ;
111
116
self_param = Some ( binding_id) ;
112
117
source_map_self_param =
@@ -136,17 +141,15 @@ pub(super) fn lower_body(
136
141
{
137
142
let is_mutable =
138
143
self_param_syn. mut_token ( ) . is_some ( ) && self_param_syn. amp_token ( ) . is_none ( ) ;
139
- let binding_id: la_arena:: Idx < Binding > = collector. alloc_binding (
140
- Name :: new_symbol_root ( sym:: self_) ,
141
- BindingAnnotation :: new ( is_mutable, false ) ,
142
- ) ;
143
144
let hygiene = self_param_syn
144
145
. name ( )
145
146
. map ( |name| collector. hygiene_id_for ( name. syntax ( ) . text_range ( ) ) )
146
147
. unwrap_or ( HygieneId :: ROOT ) ;
147
- if !hygiene. is_root ( ) {
148
- collector. store . binding_hygiene . insert ( binding_id, hygiene) ;
149
- }
148
+ let binding_id: la_arena:: Idx < Binding > = collector. alloc_binding (
149
+ Name :: new_symbol_root ( sym:: self_) ,
150
+ BindingAnnotation :: new ( is_mutable, false ) ,
151
+ hygiene,
152
+ ) ;
150
153
self_param = Some ( binding_id) ;
151
154
source_map_self_param = Some ( collector. expander . in_file ( AstPtr :: new ( & self_param_syn) ) ) ;
152
155
}
@@ -486,13 +489,10 @@ impl BindingList {
486
489
hygiene : HygieneId ,
487
490
mode : BindingAnnotation ,
488
491
) -> BindingId {
489
- let id = * self . map . entry ( ( name, hygiene) ) . or_insert_with_key ( |( name, _) | {
490
- let id = ec. alloc_binding ( name. clone ( ) , mode) ;
491
- if !hygiene. is_root ( ) {
492
- ec. store . binding_hygiene . insert ( id, hygiene) ;
493
- }
494
- id
495
- } ) ;
492
+ let id = * self
493
+ . map
494
+ . entry ( ( name, hygiene) )
495
+ . or_insert_with_key ( |( name, hygiene) | ec. alloc_binding ( name. clone ( ) , mode, * hygiene) ) ;
496
496
if ec. store . bindings [ id] . mode != mode {
497
497
ec. store . bindings [ id] . problems = Some ( BindingProblems :: BoundInconsistently ) ;
498
498
}
@@ -1770,7 +1770,8 @@ impl ExprCollector<'_> {
1770
1770
) ;
1771
1771
let loop_outer = self
1772
1772
. alloc_expr ( Expr :: Loop { body : loop_inner, label : label. map ( |it| it. 1 ) } , syntax_ptr) ;
1773
- let iter_binding = self . alloc_binding ( iter_name, BindingAnnotation :: Mutable ) ;
1773
+ let iter_binding =
1774
+ self . alloc_binding ( iter_name, BindingAnnotation :: Mutable , HygieneId :: ROOT ) ;
1774
1775
let iter_pat = self . alloc_pat_desugared ( Pat :: Bind { id : iter_binding, subpat : None } ) ;
1775
1776
self . add_definition_to_binding ( iter_binding, iter_pat) ;
1776
1777
self . alloc_expr (
@@ -1803,8 +1804,11 @@ impl ExprCollector<'_> {
1803
1804
let expr = self
1804
1805
. alloc_expr ( Expr :: Call { callee : try_branch, args : Box :: new ( [ operand] ) } , syntax_ptr) ;
1805
1806
let continue_name = Name :: generate_new_name ( self . store . bindings . len ( ) ) ;
1806
- let continue_binding =
1807
- self . alloc_binding ( continue_name. clone ( ) , BindingAnnotation :: Unannotated ) ;
1807
+ let continue_binding = self . alloc_binding (
1808
+ continue_name. clone ( ) ,
1809
+ BindingAnnotation :: Unannotated ,
1810
+ HygieneId :: ROOT ,
1811
+ ) ;
1808
1812
let continue_bpat =
1809
1813
self . alloc_pat_desugared ( Pat :: Bind { id : continue_binding, subpat : None } ) ;
1810
1814
self . add_definition_to_binding ( continue_binding, continue_bpat) ;
@@ -1818,7 +1822,8 @@ impl ExprCollector<'_> {
1818
1822
expr : self . alloc_expr ( Expr :: Path ( Path :: from ( continue_name) ) , syntax_ptr) ,
1819
1823
} ;
1820
1824
let break_name = Name :: generate_new_name ( self . store . bindings . len ( ) ) ;
1821
- let break_binding = self . alloc_binding ( break_name. clone ( ) , BindingAnnotation :: Unannotated ) ;
1825
+ let break_binding =
1826
+ self . alloc_binding ( break_name. clone ( ) , BindingAnnotation :: Unannotated , HygieneId :: ROOT ) ;
1822
1827
let break_bpat = self . alloc_pat_desugared ( Pat :: Bind { id : break_binding, subpat : None } ) ;
1823
1828
self . add_definition_to_binding ( break_binding, break_bpat) ;
1824
1829
let break_arm = MatchArm {
@@ -3137,8 +3142,13 @@ impl ExprCollector<'_> {
3137
3142
self . alloc_expr_desugared ( Expr :: Missing )
3138
3143
}
3139
3144
3140
- fn alloc_binding ( & mut self , name : Name , mode : BindingAnnotation ) -> BindingId {
3141
- let binding = self . store . bindings . alloc ( Binding { name, mode, problems : None } ) ;
3145
+ fn alloc_binding (
3146
+ & mut self ,
3147
+ name : Name ,
3148
+ mode : BindingAnnotation ,
3149
+ hygiene : HygieneId ,
3150
+ ) -> BindingId {
3151
+ let binding = self . store . bindings . alloc ( Binding { name, mode, problems : None , hygiene } ) ;
3142
3152
if let Some ( owner) = self . current_binding_owner {
3143
3153
self . store . binding_owners . insert ( binding, owner) ;
3144
3154
}
0 commit comments