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
@@ -197,15 +197,17 @@ lint_dangling_pointers_from_locals = {$fn_kind} returns a dangling pointer to dr
197
197
.ret_ty = return type is `{$ret_ty}`
198
198
.local_var = local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}
199
199
.created_at = dangling pointer created here
200
-
.note = a dangling pointer is safe, but dereferencing one is undefined behavior
201
-
202
-
lint_dangling_pointers_from_temporaries = a dangling pointer will be produced because the temporary `{$ty}` will be dropped
203
-
.label_ptr = this pointer will immediately be invalid
204
-
.label_temporary = this `{$ty}` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
205
-
.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
206
-
.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}`
207
-
.help_returned = in particular, if this pointer is returned from the current function, binding the `{$ty}` inside the function will not suffice
208
-
.help_visit = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
200
+
.note_safe = a dangling pointer is safe, but dereferencing one is undefined behavior
201
+
.note_more_info = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
202
+
203
+
lint_dangling_pointers_from_temporaries = expression creates a dangling pointer to dropped temporary `{$ty}`
204
+
.label_ptr = dangling pointer created here
205
+
.label_temporary = this `{$ty}` is dropped at the end of the statement
206
+
.help_bind = bind the `{$ty}` to a variable such that it outlives the pointer returned by `{$callee}`
207
+
.note_safe = a dangling pointer is safe, but dereferencing one is undefined behavior
208
+
.note_return = returning a pointer to a local variable will always result in a dangling pointer
209
+
.note_more_info = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
210
+
209
211
210
212
lint_default_hash_types = prefer `{$preferred}` over `{$used}`, it has better performance
211
213
.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: expression creates a dangling pointer to dropped temporary `String`
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
+
| ------------- ^^^^^^ dangling 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 the end of the 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: expression creates a dangling pointer to dropped temporary `String`
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
+
| ------------- ^^^^^^ dangling 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 the end of the 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