@@ -184,7 +184,7 @@ impl TempSymbGen {
184184 }
185185}
186186
187- #[ derive( Debug , Clone ) ]
187+ #[ derive( Debug ) ]
188188pub ( crate ) enum InputInlineRulesOrAlgo {
189189 Rules { rules : Vec < InputInlineRule > } ,
190190 Algo { algo : AlgoApply } ,
@@ -209,20 +209,6 @@ pub(crate) struct AlgoApply {
209209 pub ( crate ) algo_impl : Box < dyn AlgoImpl > ,
210210}
211211
212- impl Clone for AlgoApply {
213- fn clone ( & self ) -> Self {
214- Self {
215- algo : self . algo . clone ( ) ,
216- rule_args : self . rule_args . clone ( ) ,
217- options : self . options . clone ( ) ,
218- head : self . head . clone ( ) ,
219- arity : self . arity ,
220- span : self . span ,
221- algo_impl : self . algo . get_impl ( ) . unwrap ( ) ,
222- }
223- }
224- }
225-
226212impl AlgoApply {
227213 pub ( crate ) fn arity ( & self ) -> Result < usize > {
228214 self . algo_impl . arity ( & self . options , & self . head , self . span )
@@ -239,7 +225,6 @@ impl Debug for AlgoApply {
239225 }
240226}
241227
242- #[ derive( Clone ) ]
243228pub ( crate ) struct MagicAlgoApply {
244229 pub ( crate ) algo : AlgoHandle ,
245230 pub ( crate ) rule_args : Vec < MagicAlgoRuleArg > ,
@@ -325,7 +310,6 @@ impl Debug for MagicAlgoApply {
325310 }
326311}
327312
328- #[ derive( Clone ) ]
329313pub ( crate ) enum AlgoRuleArg {
330314 InMem {
331315 name : Symbol ,
@@ -374,7 +358,7 @@ impl Display for AlgoRuleArg {
374358 }
375359}
376360
377- #[ derive( Debug , Clone ) ]
361+ #[ derive( Debug ) ]
378362pub ( crate ) enum MagicAlgoRuleArg {
379363 InMem {
380364 name : MagicSymbol ,
@@ -415,7 +399,7 @@ impl MagicAlgoRuleArg {
415399 }
416400}
417401
418- #[ derive( Debug , Clone ) ]
402+ #[ derive( Debug ) ]
419403pub ( crate ) struct InputProgram {
420404 pub ( crate ) prog : BTreeMap < Symbol , InputInlineRulesOrAlgo > ,
421405 pub ( crate ) out_opts : QueryOutOptions ,
@@ -568,9 +552,12 @@ impl InputProgram {
568552
569553 Err ( NoEntryError . into ( ) )
570554 }
571- pub ( crate ) fn to_normalized_program ( & self , tx : & SessionTx < ' _ > ) -> Result < NormalFormProgram > {
555+ pub ( crate ) fn into_normalized_program (
556+ self ,
557+ tx : & SessionTx < ' _ > ,
558+ ) -> Result < ( NormalFormProgram , QueryOutOptions ) > {
572559 let mut prog: BTreeMap < Symbol , _ > = Default :: default ( ) ;
573- for ( k, rules_or_algo) in & self . prog {
560+ for ( k, rules_or_algo) in self . prog {
574561 match rules_or_algo {
575562 InputInlineRulesOrAlgo :: Rules { rules } => {
576563 let mut collected_rules = vec ! [ ] ;
@@ -581,7 +568,7 @@ impl InputProgram {
581568 Symbol :: new ( & format ! ( "***{}" , counter) as & str , span)
582569 } ;
583570 let normalized_body = InputAtom :: Conjunction {
584- inner : rule. body . clone ( ) ,
571+ inner : rule. body ,
585572 span : rule. span ,
586573 }
587574 . disjunctive_normal_form ( tx) ?;
@@ -631,23 +618,18 @@ impl InputProgram {
631618 ) ;
632619 }
633620 InputInlineRulesOrAlgo :: Algo { algo : algo_apply } => {
634- prog. insert (
635- k. clone ( ) ,
636- NormalFormAlgoOrRules :: Algo {
637- algo : algo_apply. clone ( ) ,
638- } ,
639- ) ;
621+ prog. insert ( k. clone ( ) , NormalFormAlgoOrRules :: Algo { algo : algo_apply } ) ;
640622 }
641623 }
642624 }
643- Ok ( NormalFormProgram { prog } )
625+ Ok ( ( NormalFormProgram { prog } , self . out_opts ) )
644626 }
645627}
646628
647- #[ derive( Debug , Clone ) ]
629+ #[ derive( Debug ) ]
648630pub ( crate ) struct StratifiedNormalFormProgram ( pub ( crate ) Vec < NormalFormProgram > ) ;
649631
650- #[ derive( Debug , Clone ) ]
632+ #[ derive( Debug ) ]
651633pub ( crate ) enum NormalFormAlgoOrRules {
652634 Rules { rules : Vec < NormalFormInlineRule > } ,
653635 Algo { algo : AlgoApply } ,
@@ -662,15 +644,15 @@ impl NormalFormAlgoOrRules {
662644 }
663645}
664646
665- #[ derive( Debug , Clone , Default ) ]
647+ #[ derive( Debug , Default ) ]
666648pub ( crate ) struct NormalFormProgram {
667649 pub ( crate ) prog : BTreeMap < Symbol , NormalFormAlgoOrRules > ,
668650}
669651
670- #[ derive( Debug , Clone ) ]
652+ #[ derive( Debug ) ]
671653pub ( crate ) struct StratifiedMagicProgram ( pub ( crate ) Vec < MagicProgram > ) ;
672654
673- #[ derive( Debug , Clone ) ]
655+ #[ derive( Debug ) ]
674656pub ( crate ) enum MagicRulesOrAlgo {
675657 Rules { rules : Vec < MagicInlineRule > } ,
676658 Algo { algo : MagicAlgoApply } ,
@@ -697,7 +679,7 @@ impl MagicRulesOrAlgo {
697679 }
698680}
699681
700- #[ derive( Debug , Clone ) ]
682+ #[ derive( Debug ) ]
701683pub ( crate ) struct MagicProgram {
702684 pub ( crate ) prog : BTreeMap < MagicSymbol , MagicRulesOrAlgo > ,
703685}
@@ -815,22 +797,22 @@ impl MagicSymbol {
815797 }
816798}
817799
818- #[ derive( Debug , Clone ) ]
800+ #[ derive( Debug ) ]
819801pub ( crate ) struct InputInlineRule {
820802 pub ( crate ) head : Vec < Symbol > ,
821803 pub ( crate ) aggr : Vec < Option < ( Aggregation , Vec < DataValue > ) > > ,
822804 pub ( crate ) body : Vec < InputAtom > ,
823805 pub ( crate ) span : SourceSpan ,
824806}
825807
826- #[ derive( Debug , Clone ) ]
808+ #[ derive( Debug ) ]
827809pub ( crate ) struct NormalFormInlineRule {
828810 pub ( crate ) head : Vec < Symbol > ,
829811 pub ( crate ) aggr : Vec < Option < ( Aggregation , Vec < DataValue > ) > > ,
830812 pub ( crate ) body : Vec < NormalFormAtom > ,
831813}
832814
833- #[ derive( Debug , Clone ) ]
815+ #[ derive( Debug ) ]
834816pub ( crate ) struct MagicInlineRule {
835817 pub ( crate ) head : Vec < Symbol > ,
836818 pub ( crate ) aggr : Vec < Option < ( Aggregation , Vec < DataValue > ) > > ,
@@ -852,7 +834,6 @@ impl MagicInlineRule {
852834 }
853835}
854836
855- #[ derive( Clone ) ]
856837pub ( crate ) enum InputAtom {
857838 Rule {
858839 inner : InputRuleApplyAtom ,
0 commit comments