From 6a7c88cd025de15fc5b58229d8c51dafa3fe7a8d Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 27 Oct 2021 01:17:53 -0700 Subject: [PATCH] Fix clippy --- schala-lang/language/src/symbol_table/mod.rs | 4 ++-- schala-lang/language/src/symbol_table/resolver.rs | 14 +++++++------- schala-lang/language/src/tree_walk_eval/mod.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 ea89514..ce6d04f 100644 --- a/schala-lang/language/src/symbol_table/mod.rs +++ b/schala-lang/language/src/symbol_table/mod.rs @@ -214,7 +214,7 @@ impl Symbol { } pub fn def_id(&self) -> Option { - Some(self.def_id.clone()) + Some(self.def_id) } pub fn spec(&self) -> SymbolSpec { @@ -302,7 +302,7 @@ impl SymbolTable { println!("In add_symbol(), adding: {:?}", symbol); self.symbol_trie.insert(&fqsn); self.fqsn_to_symbol.insert(fqsn, symbol.clone()); - self.id_to_symbol.insert(id.clone(), symbol); + self.id_to_symbol.insert(*id, symbol); } /// Walks the AST, matching the ID of an identifier used in some expression to diff --git a/schala-lang/language/src/symbol_table/resolver.rs b/schala-lang/language/src/symbol_table/resolver.rs index 7e2effc..caaa67c 100644 --- a/schala-lang/language/src/symbol_table/resolver.rs +++ b/schala-lang/language/src/symbol_table/resolver.rs @@ -83,7 +83,7 @@ impl<'a> ScopeResolver<'a> { Some(NameType::Import(fqsn)) => { let symbol = self.symbol_table.fqsn_to_symbol.get(fqsn); if let Some(symbol) = symbol { - self.symbol_table.id_to_symbol.insert(id.clone(), symbol.clone()); + self.symbol_table.id_to_symbol.insert(*id, symbol.clone()); } }, Some(NameType::Param(n)) => { @@ -96,7 +96,7 @@ impl<'a> ScopeResolver<'a> { Some(NameType::LocalVariable(item_id)) => { let symbol = self.symbol_table.id_to_symbol.get(item_id).cloned(); if let Some(symbol) = symbol { - self.symbol_table.id_to_symbol.insert(id.clone(), symbol); + self.symbol_table.id_to_symbol.insert(*id, symbol); } }, None => { @@ -104,7 +104,7 @@ impl<'a> ScopeResolver<'a> { let fqsn = Fqsn { scopes: vec![Scope::Name(local_name.clone())] }; let symbol = self.symbol_table.fqsn_to_symbol.get(&fqsn); if let Some(symbol) = symbol { - self.symbol_table.id_to_symbol.insert(id.clone(), symbol.clone()); + self.symbol_table.id_to_symbol.insert(*id, symbol.clone()); } } } @@ -112,7 +112,7 @@ impl<'a> ScopeResolver<'a> { let fqsn = Fqsn { scopes: components.iter().map(|name| Scope::Name(name.clone())).collect() }; let symbol = self.symbol_table.fqsn_to_symbol.get(&fqsn); if let Some(symbol) = symbol { - self.symbol_table.id_to_symbol.insert(id.clone(), symbol.clone()); + self.symbol_table.id_to_symbol.insert(*id, symbol.clone()); } } } @@ -195,7 +195,7 @@ impl<'a> ASTVisitor for ScopeResolver<'a> { // We are within a function scope let fqsn = Fqsn { scopes: vec![Scope::Name(fn_name), Scope::Name(name.clone())] }; self.symbol_table.add_symbol(id, fqsn, SymbolSpec::LocalVariable); - self.lexical_scopes.insert(name.clone(), NameType::LocalVariable(id.clone())); + self.lexical_scopes.insert(name.clone(), NameType::LocalVariable(*id)); } Recursion::Continue } @@ -306,12 +306,12 @@ impl<'a> ASTVisitor for ScopeResolver<'a> { let fqsn = Fqsn { scopes: vec![lscope, Scope::Name(local_name.clone())] }; //let local_name = fqsn.local_name(); self.symbol_table.add_symbol(id, fqsn, SymbolSpec::LocalVariable); - self.lexical_scopes.insert(local_name, NameType::LocalVariable(id.clone())); + self.lexical_scopes.insert(local_name, NameType::LocalVariable(*id)); } else { let fqsn = Fqsn { scopes: components.iter().map(|name| Scope::Name(name.clone())).collect() }; let symbol = self.symbol_table.fqsn_to_symbol.get(&fqsn); if let Some(symbol) = symbol { - self.symbol_table.id_to_symbol.insert(id.clone(), symbol.clone()); + self.symbol_table.id_to_symbol.insert(*id, symbol.clone()); } } }, diff --git a/schala-lang/language/src/tree_walk_eval/mod.rs b/schala-lang/language/src/tree_walk_eval/mod.rs index 9e0189d..f7c322d 100644 --- a/schala-lang/language/src/tree_walk_eval/mod.rs +++ b/schala-lang/language/src/tree_walk_eval/mod.rs @@ -224,7 +224,7 @@ impl<'a> State<'a> { // This just checks that the function exists in "memory" by ID, we don't // actually retrieve it until `apply_function()` Some(MemoryValue::Function(_)) => { - Primitive::Callable(Callable::UserDefined(id.clone())) + Primitive::Callable(Callable::UserDefined(*id)) } x => return Err(format!("Function not found for id: {} : {:?}", id, x).into()), }