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

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

19 lines
906 B
Plaintext
Raw Normal View History

2020-08-18 16:02:23 -05:00
error: getting the inner pointer of a temporary `CString`
2020-10-26 18:19:06 -05:00
--> $DIR/lint-temporary-cstring-as-ptr.rs:7:48
2020-08-18 11:09:33 -05:00
|
LL | let s = CString::new("some text").unwrap().as_ptr();
2020-08-18 18:37:50 -05:00
| ---------------------------------- ^^^^^^ this pointer will be invalid
| |
2020-09-21 15:32:28 -05:00
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
2020-08-18 11:09:33 -05:00
|
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-08-23 13:21:58 -05:00
note: the lint level is defined here
2020-10-26 18:19:06 -05:00
--> $DIR/lint-temporary-cstring-as-ptr.rs:2:9
2020-08-23 13:21:58 -05:00
|
LL | #![deny(temporary_cstring_as_ptr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
2020-08-18 11:09:33 -05:00
error: aborting due to previous error