From 2822074b2d3acd83bccba67fc56384e12ad6deff Mon Sep 17 00:00:00 2001 From: David Mak Date: Tue, 19 Nov 2024 13:43:57 +0800 Subject: [PATCH] [meta] Cleanup from upgrading Rust version - Remove rust_2024_edition warnings, since it wouldn't be released for another 3 months - Fix new clippy warnings --- nac3artiq/src/lib.rs | 12 +++------ nac3ast/src/lib.rs | 8 +----- nac3core/build.rs | 3 +-- nac3core/src/lib.rs | 8 +----- nac3core/src/typecheck/type_inferencer/mod.rs | 5 ++-- nac3ld/src/lib.rs | 8 +----- nac3parser/src/lib.rs | 8 +----- nac3standalone/src/main.rs | 8 +----- runkernel/src/main.rs | 26 +++++++------------ 9 files changed, 21 insertions(+), 65 deletions(-) diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index 553264d..b49a88e 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -1,10 +1,4 @@ -#![deny( - future_incompatible, - let_underscore, - nonstandard_style, - clippy::all -)] -#![warn(rust_2024_compatibility)] +#![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)] #![warn(clippy::pedantic)] #![allow( unsafe_op_in_unsafe_fn, @@ -741,7 +735,7 @@ impl Nac3 { }; let return_obj = - generator.gen_expr(ctx, &expr)?.map(|value| (expr.custom.unwrap(), value)); + generator.gen_expr(ctx, expr)?.map(|value| (expr.custom.unwrap(), value)); has_return = return_obj.is_some(); registry.wait_tasks_complete(handles); attributes_writeback( @@ -765,7 +759,7 @@ impl Nac3 { let buffers = membuffers.lock(); let main = context .create_module_from_ir(MemoryBuffer::create_from_memory_range( - &buffers.last().unwrap(), + buffers.last().unwrap(), "main", )) .unwrap(); diff --git a/nac3ast/src/lib.rs b/nac3ast/src/lib.rs index e313946..7691915 100644 --- a/nac3ast/src/lib.rs +++ b/nac3ast/src/lib.rs @@ -1,10 +1,4 @@ -#![deny( - future_incompatible, - let_underscore, - nonstandard_style, - clippy::all -)] -#![warn(rust_2024_compatibility)] +#![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)] #![warn(clippy::pedantic)] #![allow( clippy::missing_errors_doc, diff --git a/nac3core/build.rs b/nac3core/build.rs index 8a5c56f..c2059a2 100644 --- a/nac3core/build.rs +++ b/nac3core/build.rs @@ -56,9 +56,8 @@ fn main() { let output = Command::new("clang-irrt") .args(flags) .output() - .map(|o| { + .inspect(|o| { assert!(o.status.success(), "{}", std::str::from_utf8(&o.stderr).unwrap()); - o }) .unwrap(); diff --git a/nac3core/src/lib.rs b/nac3core/src/lib.rs index c2faade..91ae05a 100644 --- a/nac3core/src/lib.rs +++ b/nac3core/src/lib.rs @@ -1,10 +1,4 @@ -#![deny( - future_incompatible, - let_underscore, - nonstandard_style, - clippy::all -)] -#![warn(rust_2024_compatibility)] +#![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)] #![warn(clippy::pedantic)] #![allow( dead_code, diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs index e5a6cf8..6068f63 100644 --- a/nac3core/src/typecheck/type_inferencer/mod.rs +++ b/nac3core/src/typecheck/type_inferencer/mod.rs @@ -536,9 +536,8 @@ impl<'a> Fold<()> for Inferencer<'a> { } ast::StmtKind::Assert { test, msg, .. } => { self.unify(test.custom.unwrap(), self.primitives.bool, &test.location)?; - match msg { - Some(m) => self.unify(m.custom.unwrap(), self.primitives.str, &m.location)?, - None => (), + if let Some(m) = msg { + self.unify(m.custom.unwrap(), self.primitives.str, &m.location)?; } } _ => return report_error("Unsupported statement type", stmt.location), diff --git a/nac3ld/src/lib.rs b/nac3ld/src/lib.rs index 4d5a51f..73e065d 100644 --- a/nac3ld/src/lib.rs +++ b/nac3ld/src/lib.rs @@ -1,10 +1,4 @@ -#![deny( - future_incompatible, - let_underscore, - nonstandard_style, - clippy::all -)] -#![warn(rust_2024_compatibility)] +#![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)] #![warn(clippy::pedantic)] #![allow( clippy::cast_possible_truncation, diff --git a/nac3parser/src/lib.rs b/nac3parser/src/lib.rs index 6f3fcaa..7aa6e82 100644 --- a/nac3parser/src/lib.rs +++ b/nac3parser/src/lib.rs @@ -15,13 +15,7 @@ //! //! ``` -#![deny( - future_incompatible, - let_underscore, - nonstandard_style, - clippy::all -)] -#![warn(rust_2024_compatibility)] +#![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)] #![warn(clippy::pedantic)] #![allow( clippy::enum_glob_use, diff --git a/nac3standalone/src/main.rs b/nac3standalone/src/main.rs index 698ff9c..2fce5d1 100644 --- a/nac3standalone/src/main.rs +++ b/nac3standalone/src/main.rs @@ -1,10 +1,4 @@ -#![deny( - future_incompatible, - let_underscore, - nonstandard_style, - clippy::all -)] -#![warn(rust_2024_compatibility)] +#![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)] #![warn(clippy::pedantic)] #![allow(clippy::too_many_lines, clippy::wildcard_imports)] diff --git a/runkernel/src/main.rs b/runkernel/src/main.rs index fa99f69..971f3a7 100644 --- a/runkernel/src/main.rs +++ b/runkernel/src/main.rs @@ -1,10 +1,4 @@ -#![deny( - future_incompatible, - let_underscore, - nonstandard_style, - clippy::all -)] -#![warn(rust_2024_compatibility)] +#![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)] #![warn(clippy::pedantic)] #![allow(clippy::semicolon_if_nothing_returned, clippy::uninlined_format_args)] @@ -12,47 +6,47 @@ use std::env; static mut NOW: i64 = 0; -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn now_mu() -> i64 { unsafe { NOW } } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn at_mu(t: i64) { unsafe { NOW = t } } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn delay_mu(dt: i64) { unsafe { NOW += dt } } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn rtio_init() { println!("rtio_init"); } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn rtio_get_counter() -> i64 { 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn rtio_output(target: i32, data: i32) { println!("rtio_output @{} target={target:04x} data={data}", unsafe { NOW }); } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn print_int32(x: i32) { println!("print_int32: {x}"); } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn print_int64(x: i64) { println!("print_int64: {x}"); } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn __nac3_personality(_state: u32, _exception_object: u32, _context: u32) -> u32 { unimplemented!(); }