1- use crate :: { BoundVar , DebruijnIndex , Interner , VisitResult , Visitor } ;
1+ use crate :: { BoundVar , DebruijnIndex , Interner , Visit , VisitResult , Visitor } ;
2+
3+ pub trait VisitExt < I : Interner > : Visit < I > {
4+ fn has_free_vars ( & self , interner : & I ) -> bool {
5+ self . visit_with (
6+ & mut FindFreeVarsVisitor { interner } ,
7+ DebruijnIndex :: INNERMOST ,
8+ )
9+ . to_bool ( )
10+ }
11+ }
12+
13+ impl < T , I : Interner > VisitExt < I > for T where T : Visit < I > { }
214
315#[ derive( Clone , Copy , Debug ) ]
416pub struct FindAny {
517 pub found : bool ,
618}
719
20+ impl FindAny {
21+ pub fn to_bool ( & self ) -> bool {
22+ self . found
23+ }
24+ }
25+
826impl VisitResult for FindAny {
927 fn new ( ) -> Self {
1028 FindAny { found : false }
@@ -18,11 +36,11 @@ impl VisitResult for FindAny {
1836 }
1937}
2038
21- pub struct FindBound < ' i , I : Interner > {
39+ pub struct FindFreeVarsVisitor < ' i , I : Interner > {
2240 pub interner : & ' i I ,
2341}
2442
25- impl < ' i , I : Interner > Visitor < ' i , I > for FindBound < ' i , I > {
43+ impl < ' i , I : Interner > Visitor < ' i , I > for FindFreeVarsVisitor < ' i , I > {
2644 type Result = FindAny ;
2745
2846 fn as_dyn ( & mut self ) -> & mut dyn Visitor < ' i , I , Result = Self :: Result > {
0 commit comments