Skip to content

Generate Deref assist for generic structs#20627

Open
phyBrackets wants to merge 1 commit intorust-lang:masterfrom
phyBrackets:fix/generate-deref-generic-structs
Open

Generate Deref assist for generic structs#20627
phyBrackets wants to merge 1 commit intorust-lang:masterfrom
phyBrackets:fix/generate-deref-generic-structs

Conversation

@phyBrackets
Copy link
Copy Markdown

@phyBrackets phyBrackets commented Sep 8, 2025

Fixing issue #20574

The fix ensures the assist correctly appears for generic structs without existing Deref implementations while maintaining accuracy for non-generic types.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 8, 2025
@A4-Tacks
Copy link
Copy Markdown
Member

A4-Tacks commented Sep 8, 2025

It seems that hir::Type::impls_trait behavior has changed recently.
Previously, it always returned false for generic types, but now it always returns true

@rustbot

This comment has been minimized.

@ChayimFriedman2
Copy link
Copy Markdown
Contributor

Hi @phyBrackets, are you still around?

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 9, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@phyBrackets
Copy link
Copy Markdown
Author

Hi @ChayimFriedman2 @A4-Tacks Sorry for the delay, been busy with other stuffs, I've rebased the patch onto master and updated the fix, for generic structs, instead of relying on impls_trait (which now returns true for generic types regardless of actual implementations), the fix routes through has_actual_impl which checks for concrete impl blocks in the module.

Let me know if you have any other feedback.

@phyBrackets phyBrackets force-pushed the fix/generate-deref-generic-structs branch from c0b6e33 to d9e1086 Compare April 9, 2026 05:09
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

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

I commented on the approach, but honestly I think this is entirely redundant. The behavior of impls_trait() is a bug, and we'll fix it (eventually), then there will be no need for this.

View changes since this review

}
}

fn has_actual_impl(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A much simpler and more correct approach is to list the impls by Impl::all_for_type(db, strukt.ty(db)), then filter by Impl::trait_().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is also no need to differentiate if the struct has generic args.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 15, 2026

☔ The latest upstream changes (possibly #22049) made this pull request unmergeable. Please resolve the merge conflicts.

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.

4 participants