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
+11-9Lines changed: 11 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -205,15 +205,17 @@ lint_dangling_pointers_from_locals = {$fn_kind} returns a dangling pointer to dr
205
205
.ret_ty = return type is `{$ret_ty}`
206
206
.local_var = local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}
207
207
.created_at = dangling pointer created here
208
-
.note = a dangling pointer is safe, but dereferencing one is undefined behavior
209
-
210
-
lint_dangling_pointers_from_temporaries = a dangling pointer will be produced because the temporary `{$ty}` will be dropped
211
-
.label_ptr = this pointer will immediately be invalid
212
-
.label_temporary = this `{$ty}` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
213
-
.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
214
-
.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}`
215
-
.help_returned = in particular, if this pointer is returned from the current function, binding the `{$ty}` inside the function will not suffice
216
-
.help_visit = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
208
+
.note_safe = a dangling pointer is safe, but dereferencing one is undefined behavior
209
+
.note_more_info = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
210
+
211
+
lint_dangling_pointers_from_temporaries = this creates a dangling pointer because temporary `{$ty}` is dropped at end of statement
212
+
.label_ptr = pointer created here
213
+
.label_temporary = this `{$ty}` is dropped at end of statement
214
+
.help_bind = bind the `{$ty}` to a variable such that it outlives the pointer returned by `{$callee}`
215
+
.note_safe = a dangling pointer is safe, but dereferencing one is undefined behavior
216
+
.note_return = returning a pointer to a local variable will always result in a dangling pointer
217
+
.note_more_info = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
218
+
217
219
218
220
lint_default_hash_types = prefer `{$preferred}` over `{$used}`, it has better performance
219
221
.note = a `use rustc_data_structures::fx::{$preferred}` may be necessary
Copy file name to clipboardExpand all lines: tests/ui/lint/dangling-pointers-from-temporaries/allow.stderr
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,33 @@
1
-
error: a dangling pointer will be produced because the temporary `String` will be dropped
1
+
error: this creates a dangling pointer because temporary `String` is dropped at end of statement
2
2
--> $DIR/allow.rs:9:28
3
3
|
4
4
LL | dbg!(String::new().as_ptr());
5
-
| ------------- ^^^^^^ this pointer will immediately be invalid
5
+
| ------------- ^^^^^^ pointer created here
6
6
| |
7
-
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
7
+
| this `String` is dropped at end of statement
8
8
|
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
12
-
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
9
+
= help: bind the `String` to a variable such that it outlives the pointer returned by `as_ptr`
10
+
= note: a dangling pointer is safe, but dereferencing one is undefined behavior
11
+
= note: returning a pointer to a local variable will always result in a dangling pointer
12
+
= note: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
13
13
note: the lint level is defined here
14
14
--> $DIR/allow.rs:7:12
15
15
|
16
16
LL | #[deny(dangling_pointers_from_temporaries)]
17
17
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18
18
19
-
warning: a dangling pointer will be produced because the temporary `String` will be dropped
19
+
warning: this creates a dangling pointer because temporary `String` is dropped at end of statement
20
20
--> $DIR/allow.rs:20:28
21
21
|
22
22
LL | dbg!(String::new().as_ptr());
23
-
| ------------- ^^^^^^ this pointer will immediately be invalid
23
+
| ------------- ^^^^^^ pointer created here
24
24
| |
25
-
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
25
+
| this `String` is dropped at end of statement
26
26
|
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
30
-
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
27
+
= help: bind the `String` to a variable such that it outlives the pointer returned by `as_ptr`
28
+
= note: a dangling pointer is safe, but dereferencing one is undefined behavior
29
+
= note: returning a pointer to a local variable will always result in a dangling pointer
30
+
= note: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
0 commit comments