Skip to content

Commit de0cb6c

Browse files
committed
Start work on dangling pointers lint
1 parent 0e98766 commit de0cb6c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/rustc_lint/messages.ftl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ lint_dangling_pointers_from_temporaries = a dangling pointer will be produced be
209209
.label_ptr = this pointer will immediately be invalid
210210
.label_temporary = this `{$ty}` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
211211
.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 = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
212+
.help_info = 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_info = in particular, if this pointer is returned from the current function, binding the `{$typ}` inside the function will not suffice
214+
.help_visit = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
215+
213216
214217
lint_default_hash_types = prefer `{$preferred}` over `{$used}`, it has better performance
215218
.note = a `use rustc_data_structures::fx::{$preferred}` may be necessary

compiler/rustc_lint/src/lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@ pub(crate) struct IgnoredUnlessCrateSpecified<'a> {
11481148
#[diag(lint_dangling_pointers_from_temporaries)]
11491149
#[note]
11501150
#[help]
1151+
#[help(lint_info)]
11511152
// FIXME: put #[primary_span] on `ptr_span` once it does not cause conflicts
11521153
pub(crate) struct DanglingPointersFromTemporaries<'tcx> {
11531154
pub callee: Symbol,

0 commit comments

Comments
 (0)