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

don't warn on *const c_void -> *const T casts #2677

Closed
oli-obk opened this issue Apr 17, 2018 · 2 comments
Closed

don't warn on *const c_void -> *const T casts #2677

oli-obk opened this issue Apr 17, 2018 · 2 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Apr 17, 2018

We can detect the c_void type via its path (it's defined in https://docs.rs/libc/0.2.40/src/libc/lib.rs.html#115-121 )

The user has to take care around c_void casts anyway.

cc @devonhollowood

@oli-obk oli-obk added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Apr 17, 2018
@ivanovaleksey
Copy link

Hello, seem like I came across this issue too while running clippy on Paho MQTT.
https://github.com/eclipse/paho.mqtt.rust/blob/master/src/async_client.rs#L377

error: casting from `*mut std::os::raw::c_void` to a less-strictly-aligned pointer (`*mut async_client::AsyncClient`)
   --> vendor/paho.mqtt.rust/src/async_client.rs:377:14
    |
377 |             let cli = context as *mut AsyncClient;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.194/index.html#cast_ptr_alignment

But it seems to me that it's the only possible way to work with raw pointers, so, it's legal operation.

@YaLTeR
Copy link

YaLTeR commented Apr 17, 2018

Yep, came across this in a FFI wrapper crate I'm working on as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

No branches or pull requests

3 participants