Add accurate targeting for imperfect derives diagnostic in E0277 - #159363
Conversation
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.
e4402f3 to
8575e8b
Compare
This comment has been minimized.
This comment has been minimized.
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! |
| | | ||
| LL | #[derive(Clone)] | ||
| | ----- in this derive macro expansion | ||
| LL | struct List<T> { |
There was a problem hiding this comment.
Doesn't this span need to point at T, not the name of the type? (it looks like this wasn't something you did, but was already off)
There was a problem hiding this comment.
Confirmed, this is existing span issue. Feel free to file a separate issue for it if you think it's worth tracking.
| LL | require_clone(S::<X>(PhantomData)); | ||
| | ------------- ^^^^^^^^^^^ the trait `Clone` is not implemented for `S<X>` |
There was a problem hiding this comment.
this span also looks a bit off 🤔
|
Reminder, once the PR becomes ready for a review, use |
8575e8b to
ab83e7d
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. |
This comment has been minimized.
This comment has been minimized.
Filters out false positives for the 'imperfect derives' E0277 note by checking if ADT fields satisfy the trait independently of the failing generic parameter.
ab83e7d to
e735229
Compare
This comment has been minimized.
This comment has been minimized.
Add accurate targeting for imperfect derives diagnostic in `E0277` 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 (like `PhantomData<T>`) still correctly emit the help note. r? @estebank cc @mejrs @khyperia
…17, r=mejrs Add accurate targeting for imperfect derives diagnostic in `E0277` Resolves rust-lang#157117 Follow-up rust-lang#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 (like `PhantomData<T>`) still correctly emit the help note. r? @estebank cc @mejrs @khyperia
|
@bors yield to rollup |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #161997. |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 4545c83 (parent) -> d0ea9cd (this PR) Test differencesShow 11 test diffsStage 1
Stage 2
Additionally, 2 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard d0ea9cd00084a023259154a8631075bdbc1713ea --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (d0ea9cd): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (secondary 3.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 14.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 474.853s -> 474.031s (-0.17%) |
View all comments
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