rust-lang/rust-clippy

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

Open

#1,236 创建于 2016年9月19日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)Rust (1,391 fork)batch import
A-lintL-correctnessT-middlegood first issue

仓库指标

Star
 (10,406 star)
PR 合并指标
 (平均合并 19天 22小时) (30 天内合并 113 个 PR)

描述

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.

贡献者指南