Skip to content

False positives selecting system allocator #2373

Open
@birkenfeld

Description

@birkenfeld

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveT-macrosType: Issues with macros and macro expansiongood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions