diff options
| author | Anthony Eid <hello@anthonyeid.me> | 2024-11-13 00:38:53 -0500 |
|---|---|---|
| committer | Anthony Eid <hello@anthonyeid.me> | 2024-12-05 06:12:27 -0500 |
| commit | de0cb6cb6e7cdc3d0f47378ec54b37c9f011a49e (patch) | |
| tree | 0534025877f6b555687f49f0543eacfee0e68c86 | |
| parent | 0e98766a5478abd9a279777e55e3d3e06e1761c0 (diff) | |
| download | rust-de0cb6cb6e7cdc3d0f47378ec54b37c9f011a49e.tar.gz rust-de0cb6cb6e7cdc3d0f47378ec54b37c9f011a49e.zip | |
Start work on dangling pointers lint
| -rw-r--r-- | compiler/rustc_lint/messages.ftl | 5 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/lints.rs | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 49e6b763590..da8401ebaf8 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -209,7 +209,10 @@ lint_dangling_pointers_from_temporaries = a dangling pointer will be produced be .label_ptr = this pointer will immediately be invalid .label_temporary = this `{$ty}` is deallocated at the end of the statement, bind it to a variable to extend its lifetime .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 - .help = for more information, see <https://doc.rust-lang.org/reference/destructors.html> + .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}` + .help_info = in particular, if this pointer is returned from the current function, binding the `{$typ}` inside the function will not suffice + .help_visit = for more information, see <https://doc.rust-lang.org/reference/destructors.html> + lint_default_hash_types = prefer `{$preferred}` over `{$used}`, it has better performance .note = a `use rustc_data_structures::fx::{$preferred}` may be necessary diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 20822f23bf1..382fac9c3d0 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1148,6 +1148,7 @@ pub(crate) struct IgnoredUnlessCrateSpecified<'a> { #[diag(lint_dangling_pointers_from_temporaries)] #[note] #[help] +#[help(lint_info)] // FIXME: put #[primary_span] on `ptr_span` once it does not cause conflicts pub(crate) struct DanglingPointersFromTemporaries<'tcx> { pub callee: Symbol, |
