From 43cb5d9bebe3725b8121b8c89347e02f101fc9f3 Mon Sep 17 00:00:00 2001 From: Steven Engler Date: Sun, 6 Oct 2024 17:55:58 -0400 Subject: [PATCH] Fixed `non_local_definitions` warning ```text warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> main/utility/macros.rs:148:13 | 147 | const $const_name : () = { | ---------------------- move the `impl` block outside of this associated constant `_syscall_logger_waitid` 148 | impl crate::utility::macros::SyscallLogger { | ^^^^^------------------------------------- | | | `SyscallLogger` is not local | ::: main/host/syscall/handler/wait.rs:232:5 | 232 | / log_syscall!( 233 | | waitid, 234 | | /* rv */ kernel_pid_t, 235 | | /* which */ c_int, ... | 239 | | /* uru */ *const std::ffi::c_void, 240 | | ); | |_____- in this macro invocation | = note: the macro `log_syscall` defines the non-local `impl`, and may need to be changed = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue = note: this warning originates in the macro `log_syscall` (in Nightly builds, run with -Z macro-backtrace for more info) ``` --- src/main/utility/macros.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/utility/macros.rs b/src/main/utility/macros.rs index 532e72a9db..4ad282607c 100644 --- a/src/main/utility/macros.rs +++ b/src/main/utility/macros.rs @@ -140,10 +140,13 @@ macro_rules! log_syscall { paste::paste! { log_syscall!([< _syscall_logger_ $name >]; $name, $rv, $($args),*); } }; ($const_name:ident; $name:ident, $rv:ty, $($args:ty),*) => { - // we use a constant as a hack so that we can do "impl SyscallLogger { ... }" while - // already inside a "impl SyscallHandler { ... }" block + // We use a constant as a hack so that we can do "impl SyscallLogger { ... }" while already + // inside a "impl SyscallHandler { ... }" block. Apparently they may make this a hard error + // (with no way to opt-out with an `allow`) in the future: + // https://github.com/rust-lang/rust/issues/120363 #[doc(hidden)] #[allow(non_upper_case_globals)] + #[allow(non_local_definitions)] const $const_name : () = { impl crate::utility::macros::SyscallLogger { pub fn $name(