rust-lang / rust-lang/rust-clippy
False positives selecting system allocator
Open
Nobody has claimed this yet.
C-bug
good first issue
I-false-positive
T-macros
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
The current most recent (I hope) unstable way to select the system allocator is:
#![feature(alloc_system, global_allocator, allocator_api)]
extern crate alloc_system;
#[global_allocator]
static A: alloc_system::System = alloc_system::System;
It produces the following warnings that are nonsensical in the given context:
warning: `0 as *mut _` detected. Consider using `ptr::null_mut()`
--> src/main.rs:28:1
|
28 | static A: alloc_system::System = alloc_system::System;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(zero_ptr)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.180/index.html#zero_ptr
warning: The function/method `alloc::heap::Alloc::usable_size` doesn't need a mutable reference
--> src/main.rs:28:1
|
28 | static A: alloc_system::System = alloc_system::System;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unnecessary_mut_passed)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.180/index.html#unnecessary_mut_passed
If this select-the-allocator API is to be stabilized eventually, these should be fixed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the shown global allocator example and inspect why the zero_ptr and unnecessary_mut_passed warnings are emitted at the allocator declaration. Done means selecting alloc_system::System no longer produces these false-positive warnings while the lints still catch their intended cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100