rust/tests/ui/lint/lint-temporary-cstring-as-ptr.rs

18 lines
485 B
Rust
Raw Normal View History

2020-09-22 10:20:06 -05:00
// this program is not technically incorrect, but is an obscure enough style to be worth linting
2020-08-23 13:21:58 -05:00
#![deny(temporary_cstring_as_ptr)]
2020-08-18 11:09:33 -05:00
use std::ffi::CString;
macro_rules! mymacro {
() => {
let s = CString::new("some text").unwrap().as_ptr();
//~^ ERROR getting the inner pointer of a temporary `CString`
}
}
2020-08-18 11:09:33 -05:00
fn main() {
2020-10-26 18:19:06 -05:00
let s = CString::new("some text").unwrap().as_ptr();
//~^ ERROR getting the inner pointer of a temporary `CString`
mymacro!();
2020-08-18 11:09:33 -05:00
}