rust/tests/ui/lint/lint-temporary-cstring-as-param.stderr

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

19 lines
917 B
Plaintext
Raw Normal View History

2020-09-21 15:32:28 -05:00
error: getting the inner pointer of a temporary `CString`
2020-10-27 09:10:30 -05:00
--> $DIR/lint-temporary-cstring-as-param.rs:9:45
2020-09-21 15:32:28 -05:00
|
LL | some_function(CString::new("").unwrap().as_ptr());
| ------------------------- ^^^^^^ this pointer will be invalid
| |
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
2022-09-18 10:55:36 -05:00
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: for more information, see https://doc.rust-lang.org/reference/destructors.html
2020-09-21 15:32:28 -05:00
note: the lint level is defined here
2020-10-26 18:19:06 -05:00
--> $DIR/lint-temporary-cstring-as-param.rs:1:9
2020-09-21 15:32:28 -05:00
|
LL | #![deny(temporary_cstring_as_ptr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error