@@ -951,7 +951,6 @@ fn add_template_specs(obj_specs: &mut Vec<Arc<ObjectSpec>>,
951951 while let Some ( ( _, tpl) ) = queue. pop ( ) {
952952 // TODO: here we would have to consider cond when conditional
953953 // is/imports exist
954-
955954 if used_templates. contains ( & tpl. name ) {
956955 continue ;
957956 }
@@ -961,22 +960,25 @@ fn add_template_specs(obj_specs: &mut Vec<Arc<ObjectSpec>>,
961960 let mut modifications = vec ! [ ] ;
962961 if let Some ( templ_specs) = each_stmts. get ( & tpl. name ) {
963962 for ( needed_templates, spec) in templ_specs {
963+ let mut can_add = true ;
964964 for templ in needed_templates {
965965 if !used_templates. contains ( templ. as_str ( ) ) {
966966 // We will need to re-add a check for this template,
967967 // in case it will appear later in the queue
968968 modifications. push ( ( templ. clone ( ) ,
969969 needed_templates. clone ( ) ,
970970 Arc :: clone ( spec) ) ) ;
971+ can_add = false ;
971972 break ;
972- } else {
973- queue. extend ( spec. instantiations . values ( )
974- . flat_map ( |v|v. iter ( ) )
975- . map ( |t|( spec. condition . clone ( ) ,
976- Arc :: clone ( t) ) ) ) ;
977- obj_specs. push ( Arc :: clone ( spec) ) ;
978973 }
979974 }
975+ if can_add {
976+ queue. extend ( spec. instantiations . values ( )
977+ . flat_map ( |v|v. iter ( ) )
978+ . map ( |t|( spec. condition . clone ( ) ,
979+ Arc :: clone ( t) ) ) ) ;
980+ obj_specs. push ( Arc :: clone ( spec) ) ;
981+ }
980982 }
981983 }
982984 for ( name, templs, spec) in modifications {
0 commit comments