rust-lang/rust-clippy

False positives selecting system allocator

Open

#2.373 aberto em 18 de jan. de 2018

Ver no GitHub
 (3 comments) (2 reactions) (0 assignees)Rust (1.391 forks)batch import
C-bugI-false-positiveT-macrosgood first issue

Métricas do repositório

Stars
 (10.406 stars)
Métricas de merge de PR
 (Mesclagem média 19d 22h) (113 fundiu PRs em 30d)

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.

Guia do colaborador