From 9e9dde01065cd6c1ceab83b08a7cd044b50f5f77 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 29 Sep 2022 17:48:02 +0300 Subject: chore(tvix/eval): remove `nesting_level` tracking This is actually quite useless, as we can just pass `AstChildren` around after partially consuming it. Change-Id: If0aefa2b53fc801fced1ae0709bff93966bf19f8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6804 Tested-by: BuildkiteCI Reviewed-by: grfn --- tvix/eval/src/compiler/bindings.rs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'tvix') diff --git a/tvix/eval/src/compiler/bindings.rs b/tvix/eval/src/compiler/bindings.rs index 91a2b8b535d5..0f12511df12c 100644 --- a/tvix/eval/src/compiler/bindings.rs +++ b/tvix/eval/src/compiler/bindings.rs @@ -43,9 +43,6 @@ struct AttributeSet { /// All internal entries entries: Vec<(Span, AstChildren, ast::Expr)>, - - /// How deeply nested is this attribute set in the literal definition? - nesting_level: usize, } impl ToSpan for AttributeSet { @@ -82,7 +79,6 @@ impl Binding { Binding::Plain { expr } => match expr { ast::Expr::AttrSet(existing) => { let nested = AttributeSet { - nesting_level: 0, // TODO span: c.span_for(existing), // Kind of the attrs depends on the first time it is @@ -189,7 +185,6 @@ impl TrackedBindings { fn try_merge>( &mut self, c: &mut Compiler, - _nesting_level: usize, span: Span, path: I, value: ast::Expr, @@ -243,8 +238,6 @@ trait HasEntryProxy { &self, file: Arc, ) -> Box, ast::Expr)>>; - - fn nesting_level(&self) -> usize; } impl HasEntryProxy for N { @@ -264,10 +257,6 @@ impl HasEntryProxy for N { ) })) } - - fn nesting_level(&self) -> usize { - 0 - } } impl HasEntryProxy for AttributeSet { @@ -281,10 +270,6 @@ impl HasEntryProxy for AttributeSet { ) -> Box, ast::Expr)>> { Box::new(self.entries.clone().into_iter()) } - - fn nesting_level(&self) -> usize { - self.nesting_level - } } /// AST-traversing functions related to bindings. @@ -448,16 +433,8 @@ impl Compiler<'_> { ) where N: ToSpan + HasEntryProxy, { - for (span, path, value) in node.attributes(self.file.clone()) { - let mut path = path.skip(node.nesting_level()); - - if bindings.try_merge( - self, - node.nesting_level(), - span, - path.clone(), - value.clone(), - ) { + for (span, mut path, value) in node.attributes(self.file.clone()) { + if bindings.try_merge(self, span, path.clone(), value.clone()) { // Binding is nested, or already exists and was merged, move on. continue; } -- cgit 1.4.1