fixed clippy lints

This commit is contained in:
2026-02-14 11:50:36 +00:00
parent c67217a6b8
commit 25a59a6b19
5 changed files with 9 additions and 25 deletions
+2 -2
View File
@@ -83,7 +83,7 @@ impl MemoryUnit for MainStore {
#[inline] #[inline]
fn read_word(&mut self, addr: u32) -> Result<u32, ProcessorError> { fn read_word(&mut self, addr: u32) -> Result<u32, ProcessorError> {
if addr % 4 != 0 { if !addr.is_multiple_of(4) {
return Err(ProcessorError::BadMemoryAccess(addr)); return Err(ProcessorError::BadMemoryAccess(addr));
} }
@@ -116,7 +116,7 @@ impl MemoryUnit for MainStore {
#[inline] #[inline]
fn write_word(&mut self, addr: u32, value: u32) -> Result<(), ProcessorError> { fn write_word(&mut self, addr: u32, value: u32) -> Result<(), ProcessorError> {
if addr % 4 != 0 { if !addr.is_multiple_of(4) {
return Err(ProcessorError::BadMemoryAccess(addr)); return Err(ProcessorError::BadMemoryAccess(addr));
} }
-1
View File
@@ -290,7 +290,6 @@ impl RegFile {
}) })
} }
#[must_use]
pub const fn get(&self, reg: Register) -> Result<u32, ProcessorError> { pub const fn get(&self, reg: Register) -> Result<u32, ProcessorError> {
Ok(match reg { Ok(match reg {
Register::Rg0 => self.rg0, Register::Rg0 => self.rg0,
@@ -21,10 +21,6 @@ pub struct Processor {
pub cache: Cache, pub cache: Cache,
} }
fn log(message: &str) {
println!("\x1b[32mINFO:\x1b[0m {message}");
}
impl Processor { impl Processor {
#[must_use] #[must_use]
pub fn new(memory: Box<dyn MemoryUnit>, io_devices: Vec<Arc<dyn IODevice>>) -> Self { pub fn new(memory: Box<dyn MemoryUnit>, io_devices: Vec<Arc<dyn IODevice>>) -> Self {
+6 -14
View File
@@ -117,10 +117,7 @@ impl Editor {
.file_name() .file_name()
.unwrap_or_else(|| OsStr::new("Unnamed!")) .unwrap_or_else(|| OsStr::new("Unnamed!"))
.to_str() .to_str()
.map_or_else( .unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|| unreachable!("File name should be valid UTF-8."),
|ext| ext,
);
} }
"Unnamed!" "Unnamed!"
} }
@@ -129,12 +126,9 @@ impl Editor {
if let Some(path) = &self.path { if let Some(path) = &self.path {
return path return path
.extension() .extension()
.map_or_else(|| OsStr::new("Unknown!"), |ext| ext) .unwrap_or_else(|| OsStr::new("Unknown!"))
.to_str() .to_str()
.map_or_else( .unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|| unreachable!("File name should be valid UTF-8."),
|ext| ext,
);
} }
"Unknown!" "Unknown!"
} }
@@ -398,7 +392,7 @@ impl Editor {
_ => Syntax::default(), _ => Syntax::default(),
}; };
let ed = CodeEditor::default() let mut editor = CodeEditor::default()
.id_source("editor") .id_source("editor")
.with_fontsize(12.0) .with_fontsize(12.0)
.with_rows(0) .with_rows(0)
@@ -407,8 +401,6 @@ impl Editor {
.with_numlines(true) .with_numlines(true)
.desired_width(available_width - 500.0); .desired_width(available_width - 500.0);
let mut editor = ed.clone();
editor.show(ui, &mut self.text); editor.show(ui, &mut self.text);
} }
@@ -451,7 +443,7 @@ impl Editor {
Some("dsc") => { Some("dsc") => {
let output_path = Path::new(path).with_extension("dsa"); let output_path = Path::new(path).with_extension("dsa");
if let Err(e) = compiler::compile_file(path, &output_path) { if let Err(e) = compiler::compile_file(path, &output_path) {
self.error = Some(format!("Compiler error: {}", e)); self.error = Some(format!("Compiler error: {e}"));
} }
let mut compiler = CompilerEngine::new(); let mut compiler = CompilerEngine::new();
@@ -461,7 +453,7 @@ impl Editor {
let instructions = match compiler.wait_for_result() { let instructions = match compiler.wait_for_result() {
Ok(instructions) => instructions, Ok(instructions) => instructions,
Err(e) => { Err(e) => {
self.error = Some(format!("Assembler error: {}", e)); self.error = Some(format!("Assembler error: {e}"));
return; return;
} }
}; };
+1 -4
View File
@@ -79,10 +79,7 @@ impl Loader {
.file_name() .file_name()
.unwrap_or_else(|| OsStr::new("Unnamed!")) .unwrap_or_else(|| OsStr::new("Unnamed!"))
.to_str() .to_str()
.map_or_else( .unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|| unreachable!("File name should be valid UTF-8."),
|ext| ext,
);
} }
"Unnamed!" "Unnamed!"
} }