rust-lang/rust-clippy

False positives selecting system allocator

Open

#2373 aperta il 18 gen 2018

Vedi su GitHub
 (3 commenti) (2 reazioni) (0 assegnatari)Rust (1391 fork)batch import
C-bugI-false-positiveT-macrosgood first issue

Metriche repository

Star
 (10.406 star)
Metriche merge PR
 (Merge medio 19g 22h) (113 PR mergiate in 30 g)

Descrizione

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.

Guida contributor