@@ -499,18 +499,20 @@ impl SyntaxContext {
499
499
/// This returns `None` if the context cannot be glob-adjusted.
500
500
/// Otherwise, it returns the scope to use when privacy checking (see `adjust` for details).
501
501
pub fn glob_adjust ( & mut self , expansion : Mark , glob_span : Span ) -> Option < Option < Mark > > {
502
- let mut scope = None ;
503
- let mut glob_ctxt = glob_span. ctxt ( ) . modern ( ) ;
504
- while !expansion. outer_is_descendant_of ( glob_ctxt) {
505
- scope = Some ( glob_ctxt. remove_mark ( ) ) ;
506
- if self . remove_mark ( ) != scope. unwrap ( ) {
502
+ HygieneData :: with ( |data| {
503
+ let mut scope = None ;
504
+ let mut glob_ctxt = data. modern ( glob_span. ctxt ( ) ) ;
505
+ while !data. is_descendant_of ( expansion, data. outer ( glob_ctxt) ) {
506
+ scope = Some ( data. remove_mark ( & mut glob_ctxt) ) ;
507
+ if data. remove_mark ( self ) != scope. unwrap ( ) {
508
+ return None ;
509
+ }
510
+ }
511
+ if data. adjust ( self , expansion) . is_some ( ) {
507
512
return None ;
508
513
}
509
- }
510
- if self . adjust ( expansion) . is_some ( ) {
511
- return None ;
512
- }
513
- Some ( scope)
514
+ Some ( scope)
515
+ } )
514
516
}
515
517
516
518
/// Undo `glob_adjust` if possible:
@@ -522,21 +524,23 @@ impl SyntaxContext {
522
524
/// ```
523
525
pub fn reverse_glob_adjust ( & mut self , expansion : Mark , glob_span : Span )
524
526
-> Option < Option < Mark > > {
525
- if self . adjust ( expansion) . is_some ( ) {
526
- return None ;
527
- }
527
+ HygieneData :: with ( |data| {
528
+ if data. adjust ( self , expansion) . is_some ( ) {
529
+ return None ;
530
+ }
528
531
529
- let mut glob_ctxt = glob_span. ctxt ( ) . modern ( ) ;
530
- let mut marks = Vec :: new ( ) ;
531
- while !expansion. outer_is_descendant_of ( glob_ctxt) {
532
- marks. push ( glob_ctxt . remove_mark ( ) ) ;
533
- }
532
+ let mut glob_ctxt = data . modern ( glob_span. ctxt ( ) ) ;
533
+ let mut marks = Vec :: new ( ) ;
534
+ while !data . is_descendant_of ( expansion, data . outer ( glob_ctxt) ) {
535
+ marks. push ( data . remove_mark ( & mut glob_ctxt ) ) ;
536
+ }
534
537
535
- let scope = marks. last ( ) . cloned ( ) ;
536
- while let Some ( mark) = marks. pop ( ) {
537
- * self = self . apply_mark ( mark) ;
538
- }
539
- Some ( scope)
538
+ let scope = marks. last ( ) . cloned ( ) ;
539
+ while let Some ( mark) = marks. pop ( ) {
540
+ * self = data. apply_mark ( * self , mark) ;
541
+ }
542
+ Some ( scope)
543
+ } )
540
544
}
541
545
542
546
#[ inline]
0 commit comments