Skip to content

Commit 922bd39

Browse files
committed
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 <rust-lang/rust#120363> = note: this warning originates in the macro `log_syscall` (in Nightly builds, run with -Z macro-backtrace for more info) ```
1 parent d84b563 commit 922bd39

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/utility/macros.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,13 @@ macro_rules! log_syscall {
140140
paste::paste! { log_syscall!([< _syscall_logger_ $name >]; $name, $rv, $($args),*); }
141141
};
142142
($const_name:ident; $name:ident, $rv:ty, $($args:ty),*) => {
143-
// we use a constant as a hack so that we can do "impl SyscallLogger { ... }" while
144-
// already inside a "impl SyscallHandler { ... }" block
143+
// We use a constant as a hack so that we can do "impl SyscallLogger { ... }" while already
144+
// inside a "impl SyscallHandler { ... }" block. Apparently they may make this a hard error
145+
// (with no way to opt-out with an `allow`) in the future:
146+
// https://github.com/rust-lang/rust/issues/120363
145147
#[doc(hidden)]
146148
#[allow(non_upper_case_globals)]
149+
#[allow(non_local_definitions)]
147150
const $const_name : () = {
148151
impl crate::utility::macros::SyscallLogger {
149152
pub fn $name(

0 commit comments

Comments
 (0)