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

Lint to warn about str::as_ptr() usage in ffi call #1236

Open
antoyo opened this Issue Sep 19, 2016 · 0 comments

Comments

Projects
None yet
3 participants
@antoyo

antoyo commented Sep 19, 2016

Hello.
It would be nice to have a warning when using str::as_ptr() in a ffi call instead of using CStr.

For instance, in the following code:

unsafe { printf("Hello".as_ptr() as *const _) };

should give a warning and propose something like:

let cstring = CString::new("Hello".as_bytes()).unwrap();
unsafe { printf(cstring.as_ptr()) };

Thanks to add this lint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment