Clippy 对静态声明说“参数太多”

tok*_*a-n 5 rust rust-clippy

该代码来自我的操作系统

#[global_allocator]
pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
Run Code Online (Sandbox Code Playgroud)

Clippy 说这个函数有太多参数。

error: this function has too many arguments (4/3)
  --> src/mem/allocator/heap.rs:14:1
   |
14 | pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> src/lib.rs:14:9
   |
14 | #![deny(clippy::all)]
   |         ^^^^^^^^^^^
   = note: `#[deny(clippy::too_many_arguments)]` implied by `#[deny(clippy::all)]`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
Run Code Online (Sandbox Code Playgroud)

我认为原因是global_allocator属性或linked_list_allocator板条箱,所以我使用它们编写了最少的代码。

error: this function has too many arguments (4/3)
  --> src/mem/allocator/heap.rs:14:1
   |
14 | pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> src/lib.rs:14:9
   |
14 | #![deny(clippy::all)]
   |         ^^^^^^^^^^^
   = note: `#[deny(clippy::too_many_arguments)]` implied by `#[deny(clippy::all)]`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
Run Code Online (Sandbox Code Playgroud)

然而,clippy 对这段代码只字未提。

为什么 Clippy 抱怨第一个代码?

abc*_*bet 4

如果 Clippy 在正常函数声明上抱怨这一点,请使用#[allow(clippy::too_many_arguments)]所述函数上的属性来消除错误。