@@ -104,9 +104,14 @@ pub(super) fn lower_body(
104104 {
105105 let is_mutable =
106106 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 ) ;
107111 let binding_id: la_arena:: Idx < Binding > = collector. alloc_binding (
108112 Name :: new_symbol_root ( sym:: self_) ,
109113 BindingAnnotation :: new ( is_mutable, false ) ,
114+ hygiene,
110115 ) ;
111116 self_param = Some ( binding_id) ;
112117 source_map_self_param =
@@ -136,17 +141,15 @@ pub(super) fn lower_body(
136141 {
137142 let is_mutable =
138143 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- ) ;
143144 let hygiene = self_param_syn
144145 . name ( )
145146 . map ( |name| collector. hygiene_id_for ( name. syntax ( ) . text_range ( ) ) )
146147 . 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+ ) ;
150153 self_param = Some ( binding_id) ;
151154 source_map_self_param = Some ( collector. expander . in_file ( AstPtr :: new ( & self_param_syn) ) ) ;
152155 }
@@ -486,13 +489,10 @@ impl BindingList {
486489 hygiene : HygieneId ,
487490 mode : BindingAnnotation ,
488491 ) -> 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) ) ;
496496 if ec. store . bindings [ id] . mode != mode {
497497 ec. store . bindings [ id] . problems = Some ( BindingProblems :: BoundInconsistently ) ;
498498 }
@@ -1770,7 +1770,8 @@ impl ExprCollector<'_> {
17701770 ) ;
17711771 let loop_outer = self
17721772 . 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 ) ;
17741775 let iter_pat = self . alloc_pat_desugared ( Pat :: Bind { id : iter_binding, subpat : None } ) ;
17751776 self . add_definition_to_binding ( iter_binding, iter_pat) ;
17761777 self . alloc_expr (
@@ -1803,8 +1804,11 @@ impl ExprCollector<'_> {
18031804 let expr = self
18041805 . alloc_expr ( Expr :: Call { callee : try_branch, args : Box :: new ( [ operand] ) } , syntax_ptr) ;
18051806 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+ ) ;
18081812 let continue_bpat =
18091813 self . alloc_pat_desugared ( Pat :: Bind { id : continue_binding, subpat : None } ) ;
18101814 self . add_definition_to_binding ( continue_binding, continue_bpat) ;
@@ -1818,7 +1822,8 @@ impl ExprCollector<'_> {
18181822 expr : self . alloc_expr ( Expr :: Path ( Path :: from ( continue_name) ) , syntax_ptr) ,
18191823 } ;
18201824 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 ) ;
18221827 let break_bpat = self . alloc_pat_desugared ( Pat :: Bind { id : break_binding, subpat : None } ) ;
18231828 self . add_definition_to_binding ( break_binding, break_bpat) ;
18241829 let break_arm = MatchArm {
@@ -3137,8 +3142,13 @@ impl ExprCollector<'_> {
31373142 self . alloc_expr_desugared ( Expr :: Missing )
31383143 }
31393144
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 } ) ;
31423152 if let Some ( owner) = self . current_binding_owner {
31433153 self . store . binding_owners . insert ( binding, owner) ;
31443154 }
0 commit comments