about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-29T14·48+0300
committertazjin <tazjin@tvl.su>2022-09-30T07·07+0000
commit9e9dde01065cd6c1ceab83b08a7cd044b50f5f77 (patch)
tree1e98fcd5a29bd8b48db8bce765abf644fe414010
parentccf9dd651b847aee96371b517a8375e7b4c040a6 (diff)
chore(tvix/eval): remove `nesting_level` tracking r/5000
This is actually quite useless, as we can just pass
`AstChildren<ast::Attr>` around after partially consuming it.

Change-Id: If0aefa2b53fc801fced1ae0709bff93966bf19f8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6804
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
-rw-r--r--tvix/eval/src/compiler/bindings.rs27
1 files changed, 2 insertions, 25 deletions
diff --git a/tvix/eval/src/compiler/bindings.rs b/tvix/eval/src/compiler/bindings.rs
index 91a2b8b535..0f12511df1 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::Attr>, 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<I: Iterator<Item = ast::Attr>>(
         &mut self,
         c: &mut Compiler,
-        _nesting_level: usize,
         span: Span,
         path: I,
         value: ast::Expr,
@@ -243,8 +238,6 @@ trait HasEntryProxy {
         &self,
         file: Arc<codemap::File>,
     ) -> Box<dyn Iterator<Item = (Span, AstChildren<ast::Attr>, ast::Expr)>>;
-
-    fn nesting_level(&self) -> usize;
 }
 
 impl<N: HasEntry> HasEntryProxy for N {
@@ -264,10 +257,6 @@ impl<N: HasEntry> HasEntryProxy for N {
             )
         }))
     }
-
-    fn nesting_level(&self) -> usize {
-        0
-    }
 }
 
 impl HasEntryProxy for AttributeSet {
@@ -281,10 +270,6 @@ impl HasEntryProxy for AttributeSet {
     ) -> Box<dyn Iterator<Item = (Span, AstChildren<ast::Attr>, 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;
             }