misc: clippy fixes

This commit is contained in:
2025-06-22 00:30:27 +01:00
parent 22a8785083
commit 1907bbb200
9 changed files with 21 additions and 26 deletions
Generated
+1
View File
@@ -1064,6 +1064,7 @@ dependencies = [
"rfd", "rfd",
"serde", "serde",
"toml", "toml",
"winit",
] ]
[[package]] [[package]]
+8 -8
View File
@@ -108,10 +108,10 @@ impl Parser {
let dest = expect_type!(self.next()?, Register)?; let dest = expect_type!(self.next()?, Register)?;
let mut offset = Token::Immediate(0); let mut offset = Token::Immediate(0);
if let Ok(next) = self.peek_next() { if let Ok(next) = self.peek_next()
if expect_type!(next, Immediate).is_ok() { && expect_type!(next, Immediate).is_ok()
offset = self.next()?; {
} offset = self.next()?;
} }
args = vec![base, dest, offset]; args = vec![base, dest, offset];
@@ -120,10 +120,10 @@ impl Parser {
let base = expect_type!(self.next()?, Register)?; let base = expect_type!(self.next()?, Register)?;
let dest = expect_type!(self.next()?, Register, Symbol)?; let dest = expect_type!(self.next()?, Register, Symbol)?;
let mut offset = Token::Immediate(0); let mut offset = Token::Immediate(0);
if let Ok(next) = self.peek_next() { if let Ok(next) = self.peek_next()
if expect_type!(next, Immediate).is_ok() { && expect_type!(next, Immediate).is_ok()
offset = self.next()?; {
} offset = self.next()?;
} }
args = vec![base, dest, offset]; args = vec![base, dest, offset];
} }
+4 -4
View File
@@ -23,7 +23,7 @@ fn main() {
let mut output_file = match fs::File::create(output_path) { let mut output_file = match fs::File::create(output_path) {
Ok(file) => file, Ok(file) => file,
Err(e) => { Err(e) => {
eprintln!("Failed to create output file: {}", e); eprintln!("Failed to create output file: {e}");
std::process::exit(1); std::process::exit(1);
} }
}; };
@@ -33,7 +33,7 @@ fn main() {
// Assemble the source file // Assemble the source file
if let Err(e) = engine.assemble(&src) { if let Err(e) = engine.assemble(&src) {
eprintln!("Assembly error: {}", e); eprintln!("Assembly error: {e}");
std::process::exit(1); std::process::exit(1);
} }
@@ -43,13 +43,13 @@ fn main() {
for instruction in instructions { for instruction in instructions {
if let Err(e) = output_file.write_all(&instruction.encode().to_le_bytes()) if let Err(e) = output_file.write_all(&instruction.encode().to_le_bytes())
{ {
eprintln!("Failed to write to output file: {}", e); eprintln!("Failed to write to output file: {e}");
std::process::exit(1); std::process::exit(1);
} }
} }
} }
Some(Err(e)) => { Some(Err(e)) => {
eprintln!("Build error: {}", e); eprintln!("Build error: {e}");
std::process::exit(1); std::process::exit(1);
} }
None => { None => {
+1 -1
View File
@@ -20,7 +20,7 @@ pub fn tool_libcreate() {
_ => panic!("Invalid project type"), _ => panic!("Invalid project type"),
}; };
let path = format!("{}/{}.dsa", project_path, project_name); let path = format!("{project_path}/{project_name}.dsa");
std::fs::write(path, template).expect("Unable to write file"); std::fs::write(path, template).expect("Unable to write file");
} }
+1 -1
View File
@@ -3,7 +3,7 @@ pub mod logging;
use std::io::Write; use std::io::Write;
pub fn input(prompt: &str) -> String { pub fn input(prompt: &str) -> String {
print!("{}\n > ", prompt); print!("{prompt}\n > ");
std::io::stdout().flush().unwrap(); std::io::stdout().flush().unwrap();
let mut input = String::new(); let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap(); std::io::stdin().read_line(&mut input).unwrap();
+2
View File
@@ -7,6 +7,7 @@ default-run = "emulator"
[lib] [lib]
name = "dsa_rs" name = "dsa_rs"
path = "src/lib.rs" path = "src/lib.rs"
type = "cdylib"
[[bin]] [[bin]]
name = "emulator" name = "emulator"
@@ -23,6 +24,7 @@ dirs = "6.0.0"
discord-presence = { version = "1.6.0", optional = true } discord-presence = { version = "1.6.0", optional = true }
toml = { version = "0.8.23", optional = true } toml = { version = "0.8.23", optional = true }
serde = { version = "1.0.219", features = ["derive"], optional = true } serde = { version = "1.0.219", features = ["derive"], optional = true }
winit = { version = "0.30.11", features = ["android-native-activity"] }
[features] [features]
default = ["config"] default = ["config"]
+1 -8
View File
@@ -16,14 +16,7 @@
//! //!
//! Alternatively, you can hide this in your Discord settings. //! Alternatively, you can hide this in your Discord settings.
use std::{ use std::sync::mpsc::{Receiver, Sender};
path::PathBuf,
sync::{
Arc,
mpsc::{Receiver, Sender},
},
time::Duration,
};
#[cfg(feature = "discord-rpc")] #[cfg(feature = "discord-rpc")]
use discord_presence::{Client, DiscordError, models::ActivityTimestamps}; use discord_presence::{Client, DiscordError, models::ActivityTimestamps};
+1 -1
View File
@@ -5,7 +5,7 @@ use std::{
time::Duration, time::Duration,
}; };
use crate::emulator::misc::rpc::{Activity, RpcClient}; use crate::emulator::misc::rpc::RpcClient;
use crate::emulator::system::{ use crate::emulator::system::{
model::{Command, PersistentState, Running, State}, model::{Command, PersistentState, Running, State},
processor::Processor, processor::Processor,
+2 -3
View File
@@ -344,8 +344,8 @@ impl Editor {
} }
// builds the current file // builds the current file
if ui.button("Build").clicked() && !self.unsaved { if ui.button("Build").clicked() && !self.unsaved
if let Some(path) = &self.path { && let Some(path) = &self.path {
let mut assembler = CompilerEngine::new(); let mut assembler = CompilerEngine::new();
if let Err(error) = assembler.assemble(path) { if let Err(error) = assembler.assemble(path) {
self.error = Some(format!("Failed to assemble: {error:?}")); self.error = Some(format!("Failed to assemble: {error:?}"));
@@ -371,7 +371,6 @@ impl Editor {
.flat_map(|i| i.encode().to_be_bytes().to_vec()) .flat_map(|i| i.encode().to_be_bytes().to_vec())
.collect(); .collect();
} }
}
// Loads the generated binary into the assembler at the provided offset // Loads the generated binary into the assembler at the provided offset
if ui.button("Load").clicked() { if ui.button("Load").clicked() {