From ac978864f2ba9bf24fd86b31e98170ca9583043e Mon Sep 17 00:00:00 2001 From: David Mak Date: Mon, 9 Dec 2024 12:08:23 +0800 Subject: [PATCH] [meta] Apply clippy suggestions --- nac3artiq/src/lib.rs | 7 ++++--- nac3artiq/src/symbol_resolver.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index a9d8fa1d3d..ca2f2f1529 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -1085,7 +1085,7 @@ impl Nac3 { let working_directory = tempfile::Builder::new().prefix("nac3-").tempdir().unwrap(); fs::write(working_directory.path().join("kernel.ld"), include_bytes!("kernel.ld")).unwrap(); - let mut string_store: HashMap = Default::default(); + let mut string_store: HashMap = HashMap::default(); // Keep this list of exceptions in sync with `EXCEPTION_ID_LOOKUP` in `artiq::firmware::ksupport::eh_artiq` // The exceptions declared here must be defined in `artiq.coredevice.exceptions` @@ -1120,10 +1120,11 @@ impl Nac3 { let exn_name = if name.find(':').is_none() { format!("0:artiq.coredevice.exceptions.{name}") } else { - name.to_string() + (*name).to_string() }; - string_store.insert(exn_name, i as i32); + let id = i32::try_from(i).unwrap(); + string_store.insert(exn_name, id); } Ok(Nac3 { diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs index fa57755dcb..f4509fe1c3 100644 --- a/nac3artiq/src/symbol_resolver.rs +++ b/nac3artiq/src/symbol_resolver.rs @@ -1536,7 +1536,7 @@ impl SymbolResolver for Resolver { if let Some(id) = string_store.get(s) { *id } else { - let id = string_store.len() as i32; + let id = i32::try_from(string_store.len()).unwrap(); string_store.insert(s.into(), id); id }