@@ -60,9 +60,9 @@ impl TabryConf {
6060 let mut result = vec ! [ & self . main] ;
6161
6262 for name in sub_names_vec {
63- let sub = result. last ( ) . unwrap ( ) ;
63+ let subs_here = & result. last ( ) . unwrap ( ) . subs ;
6464 let next =
65- self . find_in_subs ( & sub . subs , & sub . includes , name, false ) ?
65+ self . find_in_subs ( subs_here , name, false ) ?
6666 . ok_or ( TabryConfError :: InternalError (
6767 "sub not found in dig sub" . to_owned ( ) ,
6868 ) ) ?;
@@ -75,11 +75,10 @@ impl TabryConf {
7575 pub fn find_in_subs < ' a > (
7676 & ' a self ,
7777 subs : & ' a [ TabrySub ] ,
78- includes : & ' a Vec < String > ,
7978 name : & String ,
8079 check_aliases : bool ,
8180 ) -> Result < Option < & TabryConcreteSub > , TabryConfError > {
82- let concrete_subs: Vec < & TabryConcreteSub > = self . flatten_subs ( subs, includes ) ?;
81+ let concrete_subs: Vec < & TabryConcreteSub > = self . flatten_subs ( subs) ?;
8382
8483 for sub in concrete_subs {
8584 let sub_name = Self :: unwrap_sub_name ( sub) ?;
@@ -116,16 +115,15 @@ impl TabryConf {
116115 pub fn flatten_subs < ' a > (
117116 & ' a self ,
118117 subs : & ' a [ TabrySub ] ,
119- includes : & ' a Vec < String > ,
120118 ) -> Result < Vec < & TabryConcreteSub > , TabryConfError > {
121- let mut vecofvecs = subs
119+ let vecofvecs = subs
122120 . iter ( )
123121 . map ( |sub| match sub {
124122 TabrySub :: TabryIncludeSub { include } => {
125123 // Lookup include, which may return an error
126124 let inc = self . get_arg_include ( include) ?;
127125 // Flatten the include's subs recursively (which may return an error)
128- self . flatten_subs ( & inc. subs , & inc . includes )
126+ self . flatten_subs ( & inc. subs )
129127 }
130128 TabrySub :: TabryConcreteSub ( s) =>
131129 // This is a concrete sub, add it
@@ -135,15 +133,6 @@ impl TabryConf {
135133 } )
136134 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
137135
138- vecofvecs. extend (
139- includes. iter ( ) . map ( |include| {
140- // Lookup include, which may return an error
141- let inc = self . get_arg_include ( include) ?;
142- // Flatten the include's subs recursively (which may return an error)
143- self . flatten_subs ( & inc. subs , & inc. includes )
144- } ) . collect :: < Result < Vec < _ > , _ > > ( ) ?,
145- ) ;
146-
147136 // collect() will return an error if there were one, so now we just have flatten the
148137 // vectors
149138 Ok ( vecofvecs. into_iter ( ) . flatten ( ) . collect :: < Vec < _ > > ( ) )
@@ -154,47 +143,31 @@ impl TabryConf {
154143 pub fn expand_flags < ' a > (
155144 & ' a self ,
156145 flags : & ' a [ TabryFlag ] ,
157- includes : & ' a [ String ] ,
158146 ) -> Box < dyn Iterator < Item = & TabryConcreteFlag > + ' a > {
159147 let iter = flags. iter ( ) . flat_map ( |flag| match flag {
160148 TabryFlag :: TabryIncludeFlag { include } => {
161149 // TODO: bubble up error instead of unwrap (use get_arg_include)
162150 let include = self . arg_includes . get ( include) . unwrap ( ) ;
163- self . expand_flags ( & include. flags , & include . includes )
151+ self . expand_flags ( & include. flags )
164152 }
165153 TabryFlag :: TabryConcreteFlag ( concrete_flag) => Box :: new ( std:: iter:: once ( concrete_flag) ) ,
166154 } ) ;
167- let iter = iter. chain (
168- includes. iter ( ) . flat_map ( move |include| {
169- // TODO: bubble up error instead of unwrap
170- let inc = self . arg_includes . get ( include) . unwrap ( ) ;
171- self . expand_flags ( & inc. flags , & inc. includes )
172- } ) ,
173- ) ;
174-
175155 Box :: new ( iter)
176156 }
177157
178158 // TODO: this is an exact copy of the the above expand_flags()
179159 pub fn expand_args < ' a > (
180160 & ' a self ,
181161 args : & ' a [ TabryArg ] ,
182- includes : & ' a [ String ] ,
183162 ) -> Box < dyn Iterator < Item = & TabryConcreteArg > + ' a > {
184163 let iter = args. iter ( ) . flat_map ( |arg| match arg {
185164 TabryArg :: TabryIncludeArg { include } => {
186165 // TODO: bubble up error instead of unwrap (use get_arg_include)
187166 let include = self . arg_includes . get ( include) . unwrap ( ) ;
188- self . expand_args ( & include. args , & include . includes )
167+ self . expand_args ( & include. args )
189168 }
190169 TabryArg :: TabryConcreteArg ( concrete_arg) => Box :: new ( std:: iter:: once ( concrete_arg) ) ,
191170 } ) ;
192- let iter = iter. chain (
193- includes. iter ( ) . flat_map ( move |include| {
194- let inc = self . arg_includes . get ( include) . unwrap ( ) ;
195- self . expand_args ( & inc. args , & inc. includes )
196- } ) ,
197- ) ;
198171 Box :: new ( iter)
199172 }
200173}
0 commit comments