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
Copy file name to clipboardExpand all lines: compiler/rustc_lint/messages.ftl
+2-2
Original file line number
Diff line number
Diff line change
@@ -209,8 +209,8 @@ lint_dangling_pointers_from_temporaries = a dangling pointer will be produced be
209
209
.label_ptr = this pointer will immediately be invalid
210
210
.label_temporary = this `{$ty}` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
211
211
.note = pointers do not have a lifetime; when calling `{$callee}` the `{$ty}` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
212
-
.help_bind = you must make sure that the variable you bind the `{$typ}` to lives at least as long as the pointer returned by the call to `{$callee}`
213
-
.help_returned = in particular, if this pointer is returned from the current function, binding the `{$typ}` inside the function will not suffice
212
+
.help_bind = you must make sure that the variable you bind the `{$ty}` to lives at least as long as the pointer returned by the call to `{$callee}`
213
+
.help_returned = in particular, if this pointer is returned from the current function, binding the `{$ty}` inside the function will not suffice
214
214
.help_visit = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
215
215
216
216
lint_default_hash_types = prefer `{$preferred}` over `{$used}`, it has better performance
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
8
8
|
9
9
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
10
+
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
11
+
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
10
12
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
24
26
|
25
27
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
28
+
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
29
+
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
26
30
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
Copy file name to clipboardExpand all lines: tests/ui/lint/dangling-pointers-from-temporaries/calls.stderr
+10
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ LL | let ptr = cstring().as_ptr();
7
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: 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
10
+
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
11
+
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
10
12
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
11
13
note: the lint level is defined here
12
14
--> $DIR/calls.rs:1:9
@@ -23,6 +25,8 @@ LL | let ptr = cstring().as_ptr();
23
25
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
24
26
|
25
27
= 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
28
+
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
29
+
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
26
30
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
27
31
28
32
error: a dangling pointer will be produced because the temporary `CString` will be dropped
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
35
39
|
36
40
= 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
41
+
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
42
+
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
37
43
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
38
44
39
45
error: a dangling pointer will be produced because the temporary `CString` will be dropped
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
46
52
|
47
53
= 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
54
+
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
55
+
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
48
56
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
49
57
50
58
error: a dangling pointer will be produced because the temporary `CString` will be dropped
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
57
65
|
58
66
= 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
67
+
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
68
+
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
59
69
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
Copy file name to clipboardExpand all lines: tests/ui/lint/dangling-pointers-from-temporaries/cstring-as-ptr.stderr
+4
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@ LL | let s = CString::new("some text").unwrap().as_ptr();
15
15
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
16
16
|
17
17
= 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
18
+
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
19
+
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
18
20
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
19
21
note: the lint level is defined here
20
22
--> $DIR/cstring-as-ptr.rs:2:9
@@ -34,6 +36,8 @@ LL | mymacro!();
34
36
| ---------- in this macro invocation
35
37
|
36
38
= 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
39
+
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
40
+
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
37
41
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
38
42
= note: this error originates in the macro `mymacro` (in Nightly builds, run with -Z macro-backtrace for more info)
Copy file name to clipboardExpand all lines: tests/ui/lint/dangling-pointers-from-temporaries/example-from-issue123613.stderr
+4
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ LL | let str1 = String::with_capacity(MAX_PATH).as_mut_ptr();
7
7
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
8
8
|
9
9
= note: pointers do not have a lifetime; when calling `as_mut_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
10
+
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_mut_ptr`
11
+
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
10
12
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
11
13
note: the lint level is defined here
12
14
--> $DIR/example-from-issue123613.rs:1:9
@@ -23,6 +25,8 @@ LL | let str2 = String::from("TotototototototototototototototototoT").as_ptr
23
25
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
24
26
|
25
27
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
28
+
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
29
+
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
26
30
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
Copy file name to clipboardExpand all lines: tests/ui/lint/dangling-pointers-from-temporaries/ext.stderr
+4
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ LL | let _ptr1 = Vec::<u32>::new().as_ptr().dbg();
7
7
| this `Vec<u32>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
8
8
|
9
9
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<u32>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
10
+
= help: you must make sure that the variable you bind the `Vec<u32>` to lives at least as long as the pointer returned by the call to `as_ptr`
11
+
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u32>` inside the function will not suffice
10
12
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
11
13
note: the lint level is defined here
12
14
--> $DIR/ext.rs:1:9
@@ -23,6 +25,8 @@ LL | let _ptr2 = vec![0].as_ptr().foo();
23
25
| this `Vec<u32>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
24
26
|
25
27
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<u32>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
28
+
= help: you must make sure that the variable you bind the `Vec<u32>` to lives at least as long as the pointer returned by the call to `as_ptr`
29
+
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u32>` inside the function will not suffice
26
30
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
Copy file name to clipboardExpand all lines: tests/ui/lint/dangling-pointers-from-temporaries/methods.stderr
+4
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ LL | vec![0u8].as_ptr();
7
7
| this `Vec<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
8
8
|
9
9
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
10
+
= help: you must make sure that the variable you bind the `Vec<u8>` to lives at least as long as the pointer returned by the call to `as_ptr`
11
+
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u8>` inside the function will not suffice
10
12
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
11
13
note: the lint level is defined here
12
14
--> $DIR/methods.rs:1:9
@@ -23,6 +25,8 @@ LL | vec![0u8].as_mut_ptr();
23
25
| this `Vec<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
24
26
|
25
27
= note: pointers do not have a lifetime; when calling `as_mut_ptr` the `Vec<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
28
+
= help: you must make sure that the variable you bind the `Vec<u8>` to lives at least as long as the pointer returned by the call to `as_mut_ptr`
29
+
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u8>` inside the function will not suffice
26
30
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
0 commit comments