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
.build("getting the inner pointer of a temporary `CString`");
78
73
diag.span_label(as_ptr_span,"this pointer will be invalid");
79
74
diag.span_label(
80
75
unwrap.span,
81
-
"this `CString` is deallocated at the end of the expression, bind it to a variable to extend its lifetime",
76
+
"this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime",
82
77
);
83
-
diag.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");
78
+
diag.note("pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement...");
79
+
diag.note("...because nothing is referencing it as far as the type system is concerned");
80
+
diag.help("for more information, see https://doc.rust-lang.org/reference/destructors.html");
Copy file name to clipboardExpand all lines: src/test/ui/lint/lint-temporary-cstring-as-ptr.stderr
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,16 @@ error: getting the inner pointer of a temporary `CString`
4
4
LL | let s = CString::new("some text").unwrap().as_ptr();
5
5
| ---------------------------------- ^^^^^^ this pointer will be invalid
6
6
| |
7
-
| this `CString` is deallocated at the end of the expression, bind it to a variable to extend its lifetime
7
+
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
8
8
|
9
9
note: the lint level is defined here
10
10
--> $DIR/lint-temporary-cstring-as-ptr.rs:2:9
11
11
|
12
12
LL | #![deny(temporary_cstring_as_ptr)]
13
13
| ^^^^^^^^^^^^^^^^^^^^^^^^
14
-
= 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
14
+
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement...
15
+
= note: ...because nothing is referencing it as far as the type system is concerned
16
+
= help: for more information, see https://doc.rust-lang.org/reference/destructors.html
0 commit comments