Skip to content

Commit

Permalink
clippy run
Browse files Browse the repository at this point in the history
  • Loading branch information
lexa-diky committed Jun 26, 2024
1 parent 1125ef0 commit 59f8127
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 29 deletions.
4 changes: 0 additions & 4 deletions src/cli/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ pub(crate) enum Error {
UnknownCommand,
FileWatcher(notify::Error),
CantCrateOutputFile(std::io::Error),
CantReadInputFile(std::io::Error),
AstParsingFailed(crate::compiler::ast::Error),
Compilation(crate::compiler::Error),
}

Expand All @@ -16,8 +14,6 @@ impl Display for Error {
Error::UnknownCommand => write!(f, "Unknown command"),
Error::FileWatcher(e) => write!(f, "File watching error: {}", e),
Error::CantCrateOutputFile(e) => write!(f, "Can't create output file: {}", e),
Error::CantReadInputFile(e) => write!(f, "Can't read input file: {}", e),
Error::AstParsingFailed(e) => write!(f, "Ast parsing error: {}", e),
Error::Compilation(e) => write!(f, "Compilation error: {}", e),
}
}
Expand Down
11 changes: 1 addition & 10 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,7 @@ pub(crate) fn run_cli() {

fn handle_cli_error(cli_result: Result<(), Error>) {
if cli_result.is_err() {
match cli_result.unwrap_err() {
Error::UnknownCommand => eprintln!("unknown command"),
Error::FileWatcher(_) => eprintln!("can't create watcher"),
Error::CantCrateOutputFile(_) => eprintln!("can't create output file"),
Error::CantReadInputFile(_) => eprintln!("can't read input file"),
Error::AstParsingFailed(_) => eprintln!("ast parsing error"),
Error::Compilation(compilation_error) => {
handle_compilation_error(compilation_error)
}
}
eprintln!("{}", cli_result.unwrap_err());
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/compiler/ast/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ pub(crate) enum AstNodeType {

impl AstNodeType {
pub(crate) fn must_capture_value(&self) -> bool {
match self {
AstNodeType::AtomUtf8
matches!(self,
AstNodeType::AtomUtf8
| AstNodeType::AtomHex
| AstNodeType::AtomFnName
| AstNodeType::StatementConstName
| AstNodeType::AtomBaseNumberBase
| AstNodeType::AtomBaseNumberValue
| AstNodeType::StatementFnName
| AstNodeType::AtomFnParamIdentifier
| AstNodeType::AtomConst => true,
_ => false,
}
| AstNodeType::AtomConst
)
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/compiler/cst/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,11 @@ fn parse_atom_hex_into(node: &AstNode, buf: &mut Vec<CstAtom>) -> Result<(), Err
node_type: AstNodeType::AtomHex,
})?;

let bytes =
decode_bytes_from_string(content.as_str()).map_err(|x| Error::MalformedNodeValue {
message: format!("can't parse bytes {}", content),
let bytes = decode_bytes_from_string(content.as_str())
.map_err(|_| {
Error::MalformedNodeValue {
message: format!("can't parse bytes {}", content),
}
})?;

for byte in bytes {
Expand Down
7 changes: 0 additions & 7 deletions src/compiler/rst/compilation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ impl CompilationContext {
return self.native_function_index.find(name);
}

pub(crate) fn get_parents(&self, context_id: u64) -> Option<Vec<u64>> {
return self
.local_contexts
.get(&context_id)
.map(|it| it.parents.clone());
}

pub(crate) fn bind_parents(&mut self, context_id: u64, parents: Vec<u64>) {
self.local_contexts.entry(context_id).or_insert_with(LocalCompilationContext::new);

Expand Down

0 comments on commit 59f8127

Please sign in to comment.