Run clippy
This commit is contained in:
parent
94ee3e1897
commit
da4990107c
@ -39,11 +39,9 @@ pub fn walk_block<V: ASTVisitor>(v: &mut V, block: &Block) {
|
||||
Import(ref import_spec) => {
|
||||
v.import(import_spec);
|
||||
}
|
||||
Flow(ref flow_control) => match flow_control {
|
||||
FlowControl::Return(Some(ref retval)) => {
|
||||
Flow(ref flow_control) =>
|
||||
if let FlowControl::Return(Some(ref retval)) = flow_control {
|
||||
walk_expression(v, retval);
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
//! It defines the `Schala` type, which contains the state for a Schala REPL, and implements
|
||||
//! `ProgrammingLanguageInterface` and the chain of compiler passes for it.
|
||||
|
||||
extern crate schala_repl;
|
||||
extern crate schala_lang_codegen;
|
||||
extern crate derivative;
|
||||
extern crate schala_lang_codegen;
|
||||
extern crate schala_repl;
|
||||
|
||||
#[macro_use]
|
||||
mod util;
|
||||
|
@ -26,10 +26,7 @@ impl Parser {
|
||||
|
||||
schala_parser::program(input, self).map_err(|err: peg::error::ParseError<LineCol>| {
|
||||
let msg = err.to_string();
|
||||
ParseError {
|
||||
msg,
|
||||
location: err.location.offset.into(),
|
||||
}
|
||||
ParseError { msg, location: err.location.offset.into() }
|
||||
})
|
||||
}
|
||||
|
||||
@ -91,14 +88,14 @@ peg::parser! {
|
||||
ImportSpecifier {
|
||||
id: parser.fresh(),
|
||||
path_components,
|
||||
imported_names: suffix.unwrap_or_else(|| ImportedNames::LastOfPath)
|
||||
imported_names: suffix.unwrap_or(ImportedNames::LastOfPath)
|
||||
}
|
||||
}
|
||||
|
||||
rule path_components() -> Vec<Rc<String>> =
|
||||
"::"? name:identifier() rest:path_component()* {
|
||||
let mut items = vec![rc_string(name)];
|
||||
items.extend(rest.into_iter().map(|n| rc_string(n)));
|
||||
items.extend(rest.into_iter().map(rc_string));
|
||||
items
|
||||
}
|
||||
|
||||
@ -217,7 +214,7 @@ peg::parser! {
|
||||
__ kind:expression_kind(true, parser) _ type_anno:type_anno()? { Expression { id: parser.fresh(), type_anno, kind } }
|
||||
|
||||
rule expression_no_struct(parser: &mut Parser) -> Expression =
|
||||
__ kind:expression_kind(false, parser) { Expression { id: parser.fresh(), type_anno: None, kind: kind } }
|
||||
__ kind:expression_kind(false, parser) { Expression { id: parser.fresh(), type_anno: None, kind } }
|
||||
|
||||
rule expression_kind(struct_ok: bool, parser: &mut Parser) -> ExpressionKind =
|
||||
precedence_expr(struct_ok, parser)
|
||||
@ -568,11 +565,7 @@ impl BinopSequence {
|
||||
parser: &mut Parser,
|
||||
) -> Expression {
|
||||
let mut lhs = Expression::new(parser.fresh(), lhs);
|
||||
loop {
|
||||
let (next_op, next_rhs) = match rest.pop() {
|
||||
Some((a, b)) => (a, b),
|
||||
None => break,
|
||||
};
|
||||
while let Some((next_op, next_rhs)) = rest.pop() {
|
||||
let new_precedence = next_op.get_precedence();
|
||||
if precedence >= new_precedence {
|
||||
rest.push((next_op, next_rhs));
|
||||
|
@ -4,9 +4,7 @@ use schala_repl::{
|
||||
};
|
||||
use stopwatch::Stopwatch;
|
||||
|
||||
use crate::{
|
||||
error::SchalaError, parsing, reduced_ir, symbol_table, tree_walk_eval, type_inference,
|
||||
};
|
||||
use crate::{error::SchalaError, parsing, reduced_ir, symbol_table, tree_walk_eval, type_inference};
|
||||
|
||||
/// All the state necessary to parse and execute a Schala program are stored in this struct.
|
||||
pub struct Schala<'a> {
|
||||
@ -127,7 +125,7 @@ impl SourceReference {
|
||||
pub(crate) fn load_new_source(&mut self, source: &str) {
|
||||
self.newline_offsets = vec![];
|
||||
for (offset, ch) in source.as_bytes().iter().enumerate() {
|
||||
if *ch == ('\n' as u8) {
|
||||
if *ch == b'\n' {
|
||||
self.newline_offsets.push(offset);
|
||||
}
|
||||
}
|
||||
@ -194,7 +192,7 @@ impl<'a> ProgrammingLanguageInterface for Schala<'a> {
|
||||
self.run_pipeline(source, request.config).map_err(|schala_err| schala_err.display());
|
||||
let total_duration = sw.elapsed();
|
||||
|
||||
let stage_durations: Vec<_> = std::mem::replace(&mut self.timings, vec![])
|
||||
let stage_durations: Vec<_> = std::mem::take(&mut self.timings)
|
||||
.into_iter()
|
||||
.map(|(label, duration)| (label.to_string(), duration))
|
||||
.collect();
|
||||
|
@ -55,7 +55,7 @@ impl<'a> ScopeResolver<'a> {
|
||||
if components.len() == 1 {
|
||||
match name_type {
|
||||
Some(NameType::Import(fqsn)) => {
|
||||
let def_id = self.symbol_table.symbol_trie.lookup(&fqsn);
|
||||
let def_id = self.symbol_table.symbol_trie.lookup(fqsn);
|
||||
|
||||
if let Some(def_id) = def_id {
|
||||
self.symbol_table.id_to_def.insert(*id, def_id);
|
||||
@ -71,14 +71,14 @@ impl<'a> ScopeResolver<'a> {
|
||||
Some(NameType::LocalFunction(item_id)) => {
|
||||
let def_id = self.symbol_table.id_to_def.get(item_id);
|
||||
if let Some(def_id) = def_id {
|
||||
let def_id = def_id.clone();
|
||||
let def_id = *def_id;
|
||||
self.symbol_table.id_to_def.insert(*id, def_id);
|
||||
}
|
||||
}
|
||||
Some(NameType::LocalVariable(item_id)) => {
|
||||
let def_id = self.symbol_table.id_to_def.get(item_id);
|
||||
if let Some(def_id) = def_id {
|
||||
let def_id = def_id.clone();
|
||||
let def_id = *def_id;
|
||||
self.symbol_table.id_to_def.insert(*id, def_id);
|
||||
}
|
||||
}
|
||||
@ -87,12 +87,10 @@ impl<'a> ScopeResolver<'a> {
|
||||
self.symbol_table.id_to_def.insert(*id, def_id);
|
||||
},
|
||||
}
|
||||
} else {
|
||||
if let Some(def_id) = def_id {
|
||||
} else if let Some(def_id) = def_id {
|
||||
self.symbol_table.id_to_def.insert(*id, def_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ASTVisitor for ScopeResolver<'a> {
|
||||
|
@ -67,8 +67,7 @@ impl<'a, 'b> Evaluator<'a, 'b> {
|
||||
if self.early_returning {
|
||||
break;
|
||||
}
|
||||
if let Some(_) = self.loop_control {
|
||||
println!("We here?");
|
||||
if self.loop_control.is_some() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user