首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >克里皮对静态声明说“太多的争论”

克里皮对静态声明说“太多的争论”
EN

Stack Overflow用户
提问于 2020-09-17 07:18:27
回答 1查看 1.2K关注 0票数 3

这段代码来自我的操作系统

代码语言:javascript
复制
#[global_allocator]
pub static ALLOCATOR: LockedHeap = LockedHeap::empty();

克里皮说,这个函数有太多的参数。

代码语言:javascript
复制
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)

我认为原因是global_allocator属性或linked_list_allocator机箱,所以我使用它们编写了最低限度的代码。

代码语言:javascript
复制
#![deny(clippy::all)]
#![feature(alloc_error_handler)]
#![feature(start)]
#![feature(lang_items)]
#![no_std]

#[global_allocator]
pub static LIST: linked_list_allocator::LockedHeap = linked_list_allocator::LockedHeap::empty();

#[start]
fn _start(c: isize, v: *const *const u8) -> isize {
    3
}

#[alloc_error_handler]
fn oom(_layout: core::alloc::Layout) -> ! {
    panic!()
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
    loop {}
}

#[lang = "eh_personality"]
fn eh() {}

然而,克里皮对此代码只字未提。

为什么克里皮抱怨第一段代码?

EN

回答 1

Stack Overflow用户

发布于 2022-04-13 11:20:26

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63933070

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档