rust-lang/rust-clippy

False positives selecting system allocator

Open

#2373 opened on Jan 18, 2018

View on GitHub
 (3 comments) (2 reactions) (0 assignees)Rust (10,406 stars) (1,391 forks)batch import
C-bugI-false-positiveT-macrosgood first issue

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