From 0c6c4ef47ebaf1b378c5566e86219f6ddc574734 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Tue, 19 Oct 2021 21:18:57 -0700 Subject: [PATCH] Symbol table clippy --- schala-lang/language/src/symbol_table/mod.rs | 14 +++++++------- schala-lang/language/src/symbol_table/resolver.rs | 4 ++-- .../language/src/symbol_table/symbol_trie.rs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/schala-lang/language/src/symbol_table/mod.rs b/schala-lang/language/src/symbol_table/mod.rs index 3a3cd39..9d03aac 100644 --- a/schala-lang/language/src/symbol_table/mod.rs +++ b/schala-lang/language/src/symbol_table/mod.rs @@ -230,7 +230,7 @@ impl SymbolTable { for statement in statements { let Statement { id: _, kind, location } = statement; //TODO I'm not sure if I need to do anything with this ID let location = *location; - if let Err(err) = self.add_single_statement(kind, location, &scope_stack) { + if let Err(err) = self.add_single_statement(kind, location, scope_stack) { errors.push(err); } else { // If there's an error with a name, don't recurse into subscopes of that name let recursive_errs = match kind { @@ -260,10 +260,10 @@ impl SymbolTable { errors } - fn add_single_statement(&mut self, kind: &StatementKind, location: Location, scope_stack: &Vec) -> Result<(), SymbolError> { + fn add_single_statement(&mut self, kind: &StatementKind, location: Location, scope_stack: &[Scope]) -> Result<(), SymbolError> { match kind { StatementKind::Declaration(Declaration::FuncSig(signature)) => { - let fq_function = Fqsn::from_scope_stack(scope_stack.as_ref(), signature.name.clone()); + let fq_function = Fqsn::from_scope_stack(scope_stack, signature.name.clone()); self.fq_names.register(fq_function.clone(), NameSpec { location, kind: NameKind::Function })?; self.types.register(fq_function.clone(), NameSpec { location, kind: TypeKind } )?; @@ -274,7 +274,7 @@ impl SymbolTable { } StatementKind::Declaration(Declaration::FuncDecl(signature, ..)) => { let fn_name = &signature.name; - let fq_function = Fqsn::from_scope_stack(scope_stack.as_ref(), fn_name.clone()); + let fq_function = Fqsn::from_scope_stack(scope_stack, fn_name.clone()); self.fq_names.register(fq_function.clone(), NameSpec { location, kind: NameKind::Function })?; self.types.register(fq_function.clone(), NameSpec { location, kind: TypeKind } )?; @@ -284,11 +284,11 @@ impl SymbolTable { }); }, StatementKind::Declaration(Declaration::TypeDecl { name, .. }) => { - let fq_type = Fqsn::from_scope_stack(scope_stack.as_ref(), name.name.clone()); + let fq_type = Fqsn::from_scope_stack(scope_stack, name.name.clone()); self.types.register(fq_type, NameSpec { location, kind: TypeKind } )?; }, StatementKind::Declaration(Declaration::Binding { name, .. }) => { - let fq_binding = Fqsn::from_scope_stack(scope_stack.as_ref(), name.clone()); + let fq_binding = Fqsn::from_scope_stack(scope_stack, name.clone()); self.fq_names.register(fq_binding.clone(), NameSpec { location, kind: NameKind::Binding })?; self.add_symbol(fq_binding, Symbol { local_name: name.clone(), @@ -296,7 +296,7 @@ impl SymbolTable { }); } StatementKind::Module(ModuleSpecifier { name, .. }) => { - let fq_module = Fqsn::from_scope_stack(scope_stack.as_ref(), name.clone()); + let fq_module = Fqsn::from_scope_stack(scope_stack, name.clone()); self.fq_names.register(fq_module, NameSpec { location, kind: NameKind::Module })?; }, _ => (), diff --git a/schala-lang/language/src/symbol_table/resolver.rs b/schala-lang/language/src/symbol_table/resolver.rs index 58fa71d..14965e3 100644 --- a/schala-lang/language/src/symbol_table/resolver.rs +++ b/schala-lang/language/src/symbol_table/resolver.rs @@ -88,12 +88,12 @@ impl<'a> ASTVisitor for Resolver<'a> { } fn qualified_name(&mut self, qualified_name: &QualifiedName) { - let fqsn = self.lookup_name_in_scope(&qualified_name); + let fqsn = self.lookup_name_in_scope(qualified_name); self.symbol_table.id_to_fqsn.insert(qualified_name.id.clone(), fqsn); } fn named_struct(&mut self, qualified_name: &QualifiedName, _fields: &Vec<(Rc, Expression)>) { - let fqsn = self.lookup_name_in_scope(&qualified_name); + let fqsn = self.lookup_name_in_scope(qualified_name); self.symbol_table.id_to_fqsn.insert(qualified_name.id.clone(), fqsn); } diff --git a/schala-lang/language/src/symbol_table/symbol_trie.rs b/schala-lang/language/src/symbol_table/symbol_trie.rs index 1818701..98ef1da 100644 --- a/schala-lang/language/src/symbol_table/symbol_trie.rs +++ b/schala-lang/language/src/symbol_table/symbol_trie.rs @@ -33,7 +33,7 @@ impl SymbolTrie { Some(s) => s, None => return vec![] }; - let output: Vec = subtrie.keys().filter(|cur_key| **cur_key != *fqsn).map(|fqsn| fqsn.clone()).collect(); + let output: Vec = subtrie.keys().filter(|cur_key| **cur_key != *fqsn).cloned().collect(); output } }