This commit is contained in:
Nathan Whitaker 2020-10-27 10:10:30 -04:00
parent 39941e6281
commit 572cd358d3
2 changed files with 3 additions and 2 deletions

View File

@ -1,8 +1,9 @@
#![deny(temporary_cstring_as_ptr)]
use std::ffi::CString;
use std::os::raw::c_char;
fn some_function(data: *const i8) {}
fn some_function(data: *const c_char) {}
fn main() {
some_function(CString::new("").unwrap().as_ptr());

View File

@ -1,5 +1,5 @@
error: getting the inner pointer of a temporary `CString`
--> $DIR/lint-temporary-cstring-as-param.rs:8:45
--> $DIR/lint-temporary-cstring-as-param.rs:9:45
|
LL | some_function(CString::new("").unwrap().as_ptr());
| ------------------------- ^^^^^^ this pointer will be invalid