3
3
mod lower;
4
4
mod pretty;
5
5
pub mod scope;
6
+
6
7
#[ cfg( test) ]
7
8
mod tests;
8
9
@@ -92,11 +93,9 @@ pub struct Body {
92
93
binding_hygiene : FxHashMap < BindingId , HygieneId > ,
93
94
/// A map from an variable usages to their hygiene ID.
94
95
///
95
- /// Expressions that can be recorded here are single segment path, although not all single segments path refer
96
+ /// Expressions (and destructuing patterns) that can be recorded here are single segment path, although not all single segments path refer
96
97
/// to variables and have hygiene (some refer to items, we don't know at this stage).
97
- expr_hygiene : FxHashMap < ExprId , HygieneId > ,
98
- /// A map from a destructuring assignment possible variable usages to their hygiene ID.
99
- pat_hygiene : FxHashMap < PatId , HygieneId > ,
98
+ ident_hygiene : FxHashMap < ExprOrPatId , HygieneId > ,
100
99
}
101
100
102
101
pub type ExprPtr = AstPtr < ast:: Expr > ;
@@ -317,8 +316,7 @@ impl Body {
317
316
bindings,
318
317
binding_owners,
319
318
binding_hygiene,
320
- expr_hygiene,
321
- pat_hygiene,
319
+ ident_hygiene,
322
320
types,
323
321
} = self ;
324
322
block_scopes. shrink_to_fit ( ) ;
@@ -328,8 +326,7 @@ impl Body {
328
326
bindings. shrink_to_fit ( ) ;
329
327
binding_owners. shrink_to_fit ( ) ;
330
328
binding_hygiene. shrink_to_fit ( ) ;
331
- expr_hygiene. shrink_to_fit ( ) ;
332
- pat_hygiene. shrink_to_fit ( ) ;
329
+ ident_hygiene. shrink_to_fit ( ) ;
333
330
types. shrink_to_fit ( ) ;
334
331
}
335
332
@@ -658,11 +655,11 @@ impl Body {
658
655
}
659
656
660
657
pub fn expr_path_hygiene ( & self , expr : ExprId ) -> HygieneId {
661
- self . expr_hygiene . get ( & expr) . copied ( ) . unwrap_or ( HygieneId :: ROOT )
658
+ self . ident_hygiene . get ( & expr. into ( ) ) . copied ( ) . unwrap_or ( HygieneId :: ROOT )
662
659
}
663
660
664
661
pub fn pat_path_hygiene ( & self , pat : PatId ) -> HygieneId {
665
- self . pat_hygiene . get ( & pat) . copied ( ) . unwrap_or ( HygieneId :: ROOT )
662
+ self . ident_hygiene . get ( & pat. into ( ) ) . copied ( ) . unwrap_or ( HygieneId :: ROOT )
666
663
}
667
664
668
665
pub fn expr_or_pat_path_hygiene ( & self , id : ExprOrPatId ) -> HygieneId {
@@ -686,8 +683,7 @@ impl Default for Body {
686
683
binding_owners : Default :: default ( ) ,
687
684
self_param : Default :: default ( ) ,
688
685
binding_hygiene : Default :: default ( ) ,
689
- expr_hygiene : Default :: default ( ) ,
690
- pat_hygiene : Default :: default ( ) ,
686
+ ident_hygiene : Default :: default ( ) ,
691
687
types : Default :: default ( ) ,
692
688
}
693
689
}
0 commit comments