File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
crates/apollo-compiler/src/validation Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -573,11 +573,13 @@ impl RecursionStack {
573
573
/// if the name was used somewhere up the call stack. When a guard is dropped, its name is removed
574
574
/// from the list.
575
575
struct RecursionGuard < ' a > ( & ' a mut RecursionStack ) ;
576
+
576
577
impl RecursionGuard < ' _ > {
577
578
/// Mark that we saw a name. If there are too many names, return an error.
578
579
fn push ( & mut self , name : & Name ) -> Result < RecursionGuard < ' _ > , RecursionLimitError > {
580
+ let new = self . 0 . seen . insert ( name. clone ( ) ) ;
579
581
debug_assert ! (
580
- self . 0 . seen . insert ( name . clone ( ) ) ,
582
+ new ,
581
583
"cannot push the same name twice to RecursionGuard, check contains() first"
582
584
) ;
583
585
self . 0 . high = self . 0 . high . max ( self . 0 . seen . len ( ) ) ;
@@ -587,10 +589,12 @@ impl RecursionGuard<'_> {
587
589
Ok ( RecursionGuard ( self . 0 ) )
588
590
}
589
591
}
592
+
590
593
/// Check if we saw a name somewhere up the call stack.
591
594
fn contains ( & self , name : & Name ) -> bool {
592
- self . 0 . seen . iter ( ) . any ( |seen| seen == name)
595
+ self . 0 . seen . contains ( name)
593
596
}
597
+
594
598
/// Return the name where we started.
595
599
fn first ( & self ) -> Option < & Name > {
596
600
self . 0 . seen . first ( )
You can’t perform that action at this time.
0 commit comments