Fix clippy

This commit is contained in:
Greg Shuflin 2021-10-27 01:17:53 -07:00
parent 08590430e4
commit 6a7c88cd02
3 changed files with 10 additions and 10 deletions

View File

@ -214,7 +214,7 @@ impl Symbol {
}
pub fn def_id(&self) -> Option<DefId> {
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

View File

@ -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());
}
}
},

View File

@ -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()),
}