You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 28, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: src/test/ui/lint/lint-temporary-cstring-as-ptr.stderr
+4-7Lines changed: 4 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,12 @@
1
1
error: getting the inner pointer of a temporary `CString`
2
-
--> $DIR/lint-temporary-cstring-as-ptr.rs:6:13
2
+
--> $DIR/lint-temporary-cstring-as-ptr.rs:6:48
3
3
|
4
4
LL | let s = CString::new("some text").unwrap().as_ptr();
5
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ this pointer will be invalid
5
+
| ---------------------------------- ^^^^^^ this pointer will be invalid
6
+
| |
7
+
| this `CString` is deallocated at the end of the expression, bind it to a variable to extend its lifetime
6
8
|
7
9
= note: `#[deny(temporary_cstring_as_ptr)]` on by default
8
-
help: this `CString` is deallocated at the end of the expression, bind it to a variable to extend its lifetime
9
-
--> $DIR/lint-temporary-cstring-as-ptr.rs:6:13
10
-
|
11
-
LL | let s = CString::new("some text").unwrap().as_ptr();
12
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13
10
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` is deallocated because nothing is referencing it as far as the type system is concerned
0 commit comments