Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positives selecting system allocator #2373

Open
birkenfeld opened this issue Jan 18, 2018 · 3 comments
Open

False positives selecting system allocator #2373

birkenfeld opened this issue Jan 18, 2018 · 3 comments
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have T-macros Type: Issues with macros and macro expansion

Comments

@birkenfeld
Copy link
Contributor

birkenfeld commented Jan 18, 2018

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.

@oli-obk oli-obk added the C-bug Category: Clippy is not doing the correct thing label Jan 18, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Jan 18, 2018

Probably just needs a macro check.

@phansch phansch added good-first-issue These issues are a good way to get started with Clippy T-macros Type: Issues with macros and macro expansion labels Dec 21, 2020
@phansch
Copy link
Member

phansch commented Dec 21, 2020

Triage: Doesn't seem to trigger with custom allocators anymore, but both lints still need an external macro check.

If someone wants to get started with contributing to Clippy, I'm happy to mentor. It would be similar to this PR.

@phansch phansch added the I-false-positive Issue: The lint was triggered on code it shouldn't have label Dec 21, 2020
@samueltardieu
Copy link
Contributor

Reproducer is not usable anymore. Should we close the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

No branches or pull requests

4 participants