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.

34 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-08-18 21:02:23 +00:00
error: getting the inner pointer of a temporary `CString`
--> $DIR/lint-temporary-cstring-as-ptr.rs:14:48
2020-08-18 16:09:33 +00:00
|
LL | let s = CString::new("some text").unwrap().as_ptr();
2020-08-18 23:37:50 +00:00
| ---------------------------------- ^^^^^^ this pointer will be invalid
| |
2020-09-21 20:32:28 +00:00
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
2020-08-18 16:09:33 +00:00
|
2022-09-18 15:55:36 +00: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 18:21:58 +00:00
note: the lint level is defined here
2020-10-26 23:19:06 +00:00
--> $DIR/lint-temporary-cstring-as-ptr.rs:2:9
2020-08-23 18:21:58 +00:00
|
LL | #![deny(temporary_cstring_as_ptr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
2020-08-18 16:09:33 +00:00
error: getting the inner pointer of a temporary `CString`
--> $DIR/lint-temporary-cstring-as-ptr.rs:8:52
|
LL | let s = CString::new("some text").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
...
LL | mymacro!();
| ---------- in this macro invocation
|
= 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
= note: this error originates in the macro `mymacro` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
2020-08-18 16:09:33 +00:00