Clippy changes
This commit is contained in:
parent
68506571a8
commit
6e7bd1ccb8
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(clippy::single_char_add_str)]
|
||||||
use super::{
|
use super::{
|
||||||
Block, Declaration, Expression, ExpressionKind, ImportSpecifier, InvocationArgument, ModuleSpecifier,
|
Block, Declaration, Expression, ExpressionKind, ImportSpecifier, InvocationArgument, ModuleSpecifier,
|
||||||
Signature, Statement, StatementKind, AST,
|
Signature, Statement, StatementKind, AST,
|
||||||
@ -18,8 +19,8 @@ fn newline(buf: &mut String) {
|
|||||||
pub(super) fn render_ast(ast: &AST) -> String {
|
pub(super) fn render_ast(ast: &AST) -> String {
|
||||||
let AST { statements, .. } = ast;
|
let AST { statements, .. } = ast;
|
||||||
|
|
||||||
let mut buf = format!("(AST\n");
|
let mut buf = "(AST\n".to_string();
|
||||||
render_block(&statements, LEVEL, &mut buf);
|
render_block(statements, LEVEL, &mut buf);
|
||||||
|
|
||||||
buf.push(')');
|
buf.push(')');
|
||||||
|
|
||||||
@ -168,12 +169,12 @@ fn render_declaration(decl: &Declaration, indent: usize, buf: &mut String) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
do_indent(indent, buf);
|
do_indent(indent, buf);
|
||||||
buf.push_str(")");
|
buf.push(')');
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_block(block: &Block, indent: usize, buf: &mut String) {
|
fn render_block(block: &Block, indent: usize, buf: &mut String) {
|
||||||
for stmt in block.statements.iter() {
|
for stmt in block.statements.iter() {
|
||||||
render_statement(&stmt, indent, buf);
|
render_statement(stmt, indent, buf);
|
||||||
newline(buf);
|
newline(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ impl<'a> ASTVisitor for ScopeResolver<'a> {
|
|||||||
let mut new_scope =
|
let mut new_scope =
|
||||||
ScopeStack::new(Some(ScopeType::Function { name: signature.name.clone() }));
|
ScopeStack::new(Some(ScopeType::Function { name: signature.name.clone() }));
|
||||||
|
|
||||||
for (n, param) in param_names.enumerate().into_iter() {
|
for (n, param) in param_names.enumerate() {
|
||||||
new_scope.insert(param, NameType::Param(n as u8));
|
new_scope.insert(param, NameType::Param(n as u8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ impl<'a> ASTVisitor for ScopeResolver<'a> {
|
|||||||
//let mut new_scope = self.lexical_scopes.new_scope(Some(ScopeType::Function { name: signature.name.clone() }));
|
//let mut new_scope = self.lexical_scopes.new_scope(Some(ScopeType::Function { name: signature.name.clone() }));
|
||||||
let mut new_scope = ScopeStack::new(Some(ScopeType::Lambda));
|
let mut new_scope = ScopeStack::new(Some(ScopeType::Lambda));
|
||||||
|
|
||||||
for (n, param) in param_names.enumerate().into_iter() {
|
for (n, param) in param_names.enumerate() {
|
||||||
new_scope.insert(param, NameType::Param(n as u8));
|
new_scope.insert(param, NameType::Param(n as u8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ impl<'a, 'b> Evaluator<'a, 'b> {
|
|||||||
|
|
||||||
for statement in reduced.entrypoint.into_iter() {
|
for statement in reduced.entrypoint.into_iter() {
|
||||||
match self.statement(statement) {
|
match self.statement(statement) {
|
||||||
Ok(Some(output)) if repl => acc.push(Ok(output.to_repl(&self.type_context))),
|
Ok(Some(output)) if repl => acc.push(Ok(output.to_repl(self.type_context))),
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
acc.push(Err(error.msg));
|
acc.push(Err(error.msg));
|
||||||
|
@ -137,8 +137,7 @@ impl Primitive {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
Primitive::Object { type_id, items, tag, ordered_fields: Some(fields) } => {
|
Primitive::Object { type_id, items, tag, ordered_fields: Some(fields) } => {
|
||||||
let mut buf = format!("{}", type_context.variant_local_name(type_id, *tag).unwrap());
|
let mut buf = format!("{} {{ ", type_context.variant_local_name(type_id, *tag).unwrap());
|
||||||
write!(buf, " {{ ").unwrap();
|
|
||||||
for item in fields.iter().zip(items.iter()).map(Some).intersperse(None) {
|
for item in fields.iter().zip(items.iter()).map(Some).intersperse(None) {
|
||||||
match item {
|
match item {
|
||||||
Some((name, val)) => write!(buf, "{}: {}", name, val.to_repl(type_context)).unwrap(),
|
Some((name, val)) => write!(buf, "{}: {}", name, val.to_repl(type_context)).unwrap(),
|
||||||
|
Loading…
Reference in New Issue
Block a user