Files
rust/tests/ui/lint/dangling-pointers-from-temporaries/cstring-as-ptr.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
653 B
Rust
Raw Normal View History

2020-09-22 11:20:06 -04:00
// this program is not technically incorrect, but is an obscure enough style to be worth linting
2020-08-23 14:21:58 -04:00
#![deny(temporary_cstring_as_ptr)]
//~^ WARNING lint `temporary_cstring_as_ptr` has been renamed to `dangling_pointers_from_temporaries`
2020-08-18 12:09:33 -04:00
use std::ffi::CString;
macro_rules! mymacro {
() => {
let s = CString::new("some text").unwrap().as_ptr();
//~^ ERROR a dangling pointer will be produced because the temporary `CString` will be dropped
}
}
2020-08-18 12:09:33 -04:00
fn main() {
2020-10-26 19:19:06 -04:00
let s = CString::new("some text").unwrap().as_ptr();
//~^ ERROR a dangling pointer will be produced because the temporary `CString` will be dropped
mymacro!();
2020-08-18 12:09:33 -04:00
}