Skip to content

Conversation

@profetia
Copy link
Contributor

@profetia profetia commented Nov 2, 2025

Closes #15990

changelog: [set-contains-or-insert] fix FP when set is mutated before insert

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 2, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 2, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
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

if let ExprKind::MethodCall(_, receiver, ..) = expr.kind
&& let receiver = receiver.peel_borrows()
&& let receiver_ty = cx.typeck_results().expr_ty(receiver).peel_refs()
&& (receiver_ty.is_diag_item(cx, sym::HashSet) || receiver_ty.is_diag_item(cx, sym::BTreeSet))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
&& (receiver_ty.is_diag_item(cx, sym::HashSet) || receiver_ty.is_diag_item(cx, sym::BTreeSet))
&& matches!(receiver_ty.opt_diag_name(cx), Some(sym::HashSet | sym::BTreeSet))


let child = expr.peel_borrows();
let child_ty = cx.typeck_results().expr_ty(child).peel_refs();
if (child_ty.is_diag_item(cx, sym::HashSet) || child_ty.is_diag_item(cx, sym::BTreeSet))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (child_ty.is_diag_item(cx, sym::HashSet) || child_ty.is_diag_item(cx, sym::BTreeSet))
if matches!(child_ty.opt_diag_name(cx), Some(sym::HashSet | sym::BTreeSet))

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fp: set-contains-or-insert where set is mutated between contains and insert

4 participants