@@ -947,7 +947,7 @@ impl ExpressionStore {
947947 }
948948}
949949
950- pub trait StoreVisitor {
950+ pub trait StoreVisitor : Sized {
951951 fn on_expr ( & mut self , expr : ExprId ) {
952952 let _ = expr;
953953 }
@@ -963,6 +963,26 @@ pub trait StoreVisitor {
963963 fn on_lifetime ( & mut self , lifetime : LifetimeRefId ) {
964964 let _ = lifetime;
965965 }
966+
967+ fn on_generic_args ( & mut self , args : & GenericArgs ) {
968+ visit_generic_args ( self , args) ;
969+ }
970+ }
971+
972+ pub ( crate ) fn visit_generic_args < V : StoreVisitor > ( visitor : & mut V , args : & GenericArgs ) {
973+ let GenericArgs { args, bindings, parenthesized : _, has_self_type : _ } = args;
974+ for arg in args {
975+ match arg {
976+ GenericArg :: Type ( arg) => visitor. on_type ( * arg) ,
977+ GenericArg :: Const ( ConstRef { expr } ) => visitor. on_anon_const_expr ( * expr) ,
978+ GenericArg :: Lifetime ( arg) => visitor. on_lifetime ( * arg) ,
979+ }
980+ }
981+ for AssociatedTypeBinding { name : _, args, type_ref, bounds } in bindings {
982+ visitor. on_generic_args_opt ( args) ;
983+ visitor. on_type_opt ( * type_ref) ;
984+ visitor. on_type_bounds ( bounds) ;
985+ }
966986}
967987
968988impl < V : StoreVisitor > StoreVisitor for & mut V {
@@ -981,25 +1001,13 @@ impl<V: StoreVisitor> StoreVisitor for &mut V {
9811001 fn on_lifetime ( & mut self , lifetime : LifetimeRefId ) {
9821002 V :: on_lifetime ( self , lifetime) ;
9831003 }
984- }
9851004
986- trait StoreVisitorExt : StoreVisitor {
9871005 fn on_generic_args ( & mut self , args : & GenericArgs ) {
988- let GenericArgs { args, bindings, parenthesized : _, has_self_type : _ } = args;
989- for arg in args {
990- match arg {
991- GenericArg :: Type ( arg) => self . on_type ( * arg) ,
992- GenericArg :: Const ( ConstRef { expr } ) => self . on_anon_const_expr ( * expr) ,
993- GenericArg :: Lifetime ( arg) => self . on_lifetime ( * arg) ,
994- }
995- }
996- for AssociatedTypeBinding { name : _, args, type_ref, bounds } in bindings {
997- self . on_generic_args_opt ( args) ;
998- self . on_type_opt ( * type_ref) ;
999- self . on_type_bounds ( bounds) ;
1000- }
1006+ V :: on_generic_args ( self , args) ;
10011007 }
1008+ }
10021009
1010+ trait StoreVisitorExt : StoreVisitor {
10031011 fn on_type_bound ( & mut self , bound : & TypeBound ) {
10041012 match bound {
10051013 TypeBound :: Path ( path_id, _) => self . on_type ( path_id. type_ref ( ) ) ,
0 commit comments