@@ -39,7 +39,7 @@ type ProgNode = Arc<named::ConstructNode<Elements>>;
3939/// Bindings from inner scopes overwrite bindings from outer scopes.
4040/// Bindings live as long as their scope.
4141#[ derive( Debug , Clone ) ]
42- struct Scope {
42+ struct Scope < ' brand > {
4343 /// For each scope, the set of assigned variables.
4444 ///
4545 /// A stack of scopes. Each scope is a stack of patterns.
@@ -72,9 +72,12 @@ struct Scope {
7272 /// Values for parameters inside the SimplicityHL program.
7373 arguments : Arguments ,
7474 include_debug_symbols : bool ,
75+ // In the next commits, this will be dropped since the 'brand
76+ // tag will be moved into 'ctx'.
77+ phantom : std:: marker:: PhantomData < fn ( & ' brand ( ) ) -> & ' brand ( ) > ,
7578}
7679
77- impl Scope {
80+ impl < ' brand > Scope < ' brand > {
7881 /// Create the main scope.
7982 ///
8083 /// _This function should be called at the start of the compilation and then never again._
@@ -94,6 +97,7 @@ impl Scope {
9497 call_tracker,
9598 arguments,
9699 include_debug_symbols,
100+ phantom : core:: marker:: PhantomData ,
97101 }
98102 }
99103
@@ -105,6 +109,7 @@ impl Scope {
105109 call_tracker : Arc :: clone ( & self . call_tracker ) ,
106110 arguments : self . arguments . clone ( ) ,
107111 include_debug_symbols : self . include_debug_symbols ,
112+ phantom : core:: marker:: PhantomData ,
108113 }
109114 }
110115
@@ -221,9 +226,9 @@ impl Scope {
221226 }
222227}
223228
224- fn compile_blk (
229+ fn compile_blk < ' brand > (
225230 stmts : & [ Statement ] ,
226- scope : & mut Scope ,
231+ scope : & mut Scope < ' brand > ,
227232 index : usize ,
228233 last_expr : Option < & Expression > ,
229234) -> Result < PairBuilder < ProgNode > , RichError > {
@@ -278,7 +283,10 @@ impl Program {
278283}
279284
280285impl Expression {
281- fn compile ( & self , scope : & mut Scope ) -> Result < PairBuilder < ProgNode > , RichError > {
286+ fn compile < ' brand > (
287+ & self ,
288+ scope : & mut Scope < ' brand > ,
289+ ) -> Result < PairBuilder < ProgNode > , RichError > {
282290 match self . inner ( ) {
283291 ExpressionInner :: Block ( stmts, expr) => {
284292 scope. push_scope ( ) ;
@@ -292,7 +300,10 @@ impl Expression {
292300}
293301
294302impl SingleExpression {
295- fn compile ( & self , scope : & mut Scope ) -> Result < PairBuilder < ProgNode > , RichError > {
303+ fn compile < ' brand > (
304+ & self ,
305+ scope : & mut Scope < ' brand > ,
306+ ) -> Result < PairBuilder < ProgNode > , RichError > {
296307 let expr = match self . inner ( ) {
297308 SingleExpressionInner :: Constant ( value) => {
298309 let value = StructuralValue :: from ( value) ;
@@ -360,7 +371,10 @@ impl SingleExpression {
360371}
361372
362373impl Call {
363- fn compile ( & self , scope : & mut Scope ) -> Result < PairBuilder < ProgNode > , RichError > {
374+ fn compile < ' brand > (
375+ & self ,
376+ scope : & mut Scope < ' brand > ,
377+ ) -> Result < PairBuilder < ProgNode > , RichError > {
364378 let args_ast = SingleExpression :: tuple ( self . args ( ) . clone ( ) , * self . as_ref ( ) ) ;
365379 let args = args_ast. compile ( scope) ?;
366380
@@ -626,7 +640,10 @@ fn for_while(
626640}
627641
628642impl Match {
629- fn compile ( & self , scope : & mut Scope ) -> Result < PairBuilder < ProgNode > , RichError > {
643+ fn compile < ' brand > (
644+ & self ,
645+ scope : & mut Scope < ' brand > ,
646+ ) -> Result < PairBuilder < ProgNode > , RichError > {
630647 scope. push_scope ( ) ;
631648 scope. insert (
632649 self . left ( )
0 commit comments