Add accurate targeting for imperfect derives diagnostic in E0277 - #159363
Add accurate targeting for imperfect derives diagnostic in E0277#159363raushan728 wants to merge 1 commit into
E0277#159363Conversation
This comment has been minimized.
This comment has been minimized.
b7656d5 to
a8756f1
Compare
|
neat! I haven't looked through the PR at all, just wanted to suggest having a test with associated types as well, not just Perhaps also |
|
Thanks! Will update shortly. |
a8756f1 to
e4402f3
Compare
Done! please take a look. |
There was a problem hiding this comment.
My apologies, the logic is a bit subtle and that makes it harder to follow. Would you mind adding more comments explaining what each section is accomplishing?
I believe the changes to be directionally correct, but suspect there might be helper methods to construct the obligation with fewer moving parts.
I am currently traveling, so my response rate is lower than it otherwise would be.
Filters out false positives for the 'imperfect derives' E0277 note by checking if ADT fields satisfy the trait independently of the failing generic parameter.
e4402f3 to
8575e8b
Compare
|
This PR was rebased onto a different main 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. |
Added
I looked but didn't find an existing helper for this exact "swap self_ty, keep the rest of the trait args" pattern, so I kept the explicit construction. Open to suggestions if you know of something more idiomatic.
No worries, thanks for taking the time to review! |
Resolves #157117
Follow-up #158764
This PR implements accurate targeting for the E0277 "imperfect derives" suggestion so it only triggers when all fields of the ADT satisfy the trait independently of the failing generic parameter. False positives (like
struct S<T>(T)) are now successfully filtered out, while true cases (likePhantomData<T>) still correctly emit the help note.r? @estebank
cc @mejrs @khyperia