Add T: PartialEq bounds to derived StructuralPartialEq impls.#156807
Add T: PartialEq bounds to derived StructuralPartialEq impls.#156807kpreid wants to merge 1 commit into
T: PartialEq bounds to derived StructuralPartialEq impls.#156807Conversation
|
This PR is probably less correct than the just-posted #156809, because the documentation of Currently waiting on an answer to my question about a route to to fixing the diagnostics. |
This comment has been minimized.
This comment has been minimized.
|
Adding const X: Option<Box<()>> = None;
fn main() {
if let X = X {}
} |
|
Relevant documentation: https://doc.rust-lang.org/nightly/reference/patterns.html#r-patterns.const The Instead, the |
|
I am working on improving this PR to prevent a diagnostic regression. I believe it is possible to do so cheaply by being a little more clever about which possible error to emit (among all the errors possible to produce from different elements of the valtree being converted to a pattern). |
Fixes <rust-lang#147714>. The changes in `const_to_pat.rs` are entirely to avoid regressing diagnostic quality, and should not make any difference to what code is accepted. The change in `compute_applicable_impls_for_diagnostics` and its callers is entirely to be able to reuse that algorithm for this purpose.
|
Actually, I misunderstood the UI tests that showed the regression. The worse diagnostic is emitted in UI tests where there is a generic argument that doesn't In this case, we used to hit the error branch in I fixed that by adding a copy of the check that This should now be ready for review, but I’ll see if PR CI has anything to say first. |
|
Changes to the code generated for builtin derived traits. cc @nnethercote Some changes occurred in match checking cc @Nadrieril |
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
Add `T: PartialEq` bounds to derived `StructuralPartialEq` impls.
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
The regressions are spurious and unrelated to this PR. @rustbot label +I-lang-nominated I am nominating because this PR is a breaking change. This PR changes the behavior of #[derive(PartialEq)]
struct Thing<T>(Option<T>);Previously, the above code will cause See the reference for documentation on what's allowed as constant patterns. See the issue being fixed for compilable demonstration code that will be broken by this PR. |
|
This makes sense to me. Good (and subtle) call, in particular, on the bound being @rfcbot fcp merge lang |
|
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
Note: neither of the two regressions from the crater run is real. |
|
To clarify why this bound is correct: We want StructuralPartialEq to apply exactly at the same time that the derived PartialEq applies. That way, the promise made by StructuralPartialEq is always fulfilled by the derive. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
@rfcbot reviewed |
In other words, iiuc, we want StructuralPartialEq to have the same bounds as PartialEq, so that the impls apply for the same types. That makes sense to me. @rfcbot reviewed |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
|
@rustbot label -S-waiting-on-t-lang +S-waiting-on-review |
View all comments
Fixes #147714.
This is a breaking change to fix a bug, so it will need a crater run if it is to be done at all.
The changes in
const_to_pat.rsare entirely to avoid regressing diagnostic quality, and should not make any difference to what code is accepted. The changes incompute_applicable_impls_for_diagnosticsand its callers are entirely to be able to reuse that algorithm for this purpose.@rustbot label +T-lang