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

Extend cast_ptr_alignment for type alias #4754

Closed
tesuji opened this issue Oct 29, 2019 · 1 comment
Closed

Extend cast_ptr_alignment for type alias #4754

tesuji opened this issue Oct 29, 2019 · 1 comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@tesuji
Copy link
Contributor

tesuji commented Oct 29, 2019

This snippet only trigger cast_ptr_alignment lint non type-alias: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=bc9b2dfb6c7d2a37f96028e60b2abc1b

pub type HANDLE = *mut ::std::os::raw::c_void;
pub type PHANDLE = *mut HANDLE;

pub fn foo(_token: PHANDLE) {}

pub fn bar() {
    let mut token: HANDLE = ::std::ptr::null_mut();
    foo(token as *mut _);
    foo(&mut token);
    
    let a: *const u8 = ::std::ptr::null();
    let _ = a as *const *const u8;
}

cc #4708

@flip1995 flip1995 added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Oct 29, 2019
@JohnTitor
Copy link
Member

We already catch that case but ignore c_void, see #2677. (playground)

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