Skip to content

Conversation

@hkBst
Copy link
Member

@hkBst hkBst commented Oct 31, 2025

This cleans up the dangling_pointers_from_locals lint.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 31, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2025

r? @eholk

rustbot has assigned @eholk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Urgau
Copy link
Member

Urgau commented Oct 31, 2025

r? Urgau

@rustbot rustbot assigned Urgau and unassigned eholk Oct 31, 2025
.ret_ty = return type is `{$ret_ty}`
.local_var = local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}
.created_at = dangling pointer created here
.note = pointers do not have a lifetime; after returning, the `{$local_var_ty}` will be deallocated at the end of the {$fn_kind} because nothing is referencing it as far as the type system is concerned
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the rational for removing this note/explanation?

lint_dangling_pointers_from_locals = a dangling pointer will be produced because the local variable `{$local_var_name}` will be dropped
.ret_ty = return type of the {$fn_kind} is `{$ret_ty}`
.local_var = `{$local_var_name}` is part the {$fn_kind} and will be dropped at the end of the {$fn_kind}
lint_dangling_pointers_from_locals = {$fn_kind} returns a dangling pointer to a dropped local variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see where this is coming from, but this proposed is less descriptive about the issue. Would it be possible to still mention the name of the local variable?

It is quite useful to be able to quickly see the offending item in the main message, in particular with LSP, where we often don't have the full output of rustc.

Btw, the dangling_pointers_from_temporaries lint use a very similar warning phrasing. If we change this one, we should also change the other one for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants