Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove StructuralEq trait #116167

Merged
merged 1 commit into from Jan 26, 2024
Merged

remove StructuralEq trait #116167

merged 1 commit into from Jan 26, 2024

Conversation

RalfJung
Copy link
Member

The documentation given for the trait is outdated: all function pointers implement PartialEq and Eq these days. So the StructuralEq trait doesn't really seem to have any reason to exist any more.

One side-effect of this PR is that we allow matching on some consts that do not implement Eq. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an Eq instance. If we want to require Eq we should adjust #115893 to check for Eq, and rule out float matching for good.

Fixes #115881

@rustbot
Copy link
Collaborator

rustbot commented Sep 26, 2023

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 26, 2023
@rustbot
Copy link
Collaborator

rustbot commented Sep 26, 2023

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

Changes to the code generated for builtin derived traits.

cc @nnethercote

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@RalfJung
Copy link
Member Author

@compiler-errors you said you'd have opinions/questions about this one. :)

Cc @oli-obk @lcnr

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Sep 26, 2023

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

Changes to the code generated for builtin derived traits.

cc @nnethercote

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@lcnr
Copy link
Contributor

lcnr commented Sep 28, 2023

I agree that StructuralEq being necessary to match on custom adts while still allowing float in matches does not make sense.

I am a bit unsure whether this makes sense as a transition step. If we allow all types implementing PartialEq in matches, and require types to implement some trait StructuralMatch to opt-in to exhaustiveness checking, then I would expect the StructuralMatch trait to have an Eq super trait bound (we currently don't allow exhaustive matches on floats afaict.

Given that we currently try to use constants of all allowed types for exhaustiveness checking, allowing more types by removing the "derives Eq" requirement feels wrong.

@RalfJung
Copy link
Member Author

Given that we currently try to use constants of all allowed types for exhaustiveness checking, allowing more types by removing the "derives Eq" requirement feels wrong.

Hm, that's fair.

We could do what the comment on StructuralEq says we want to do -- have the constant participate in exhaustiveness checking only if it implements Eq. However I think that would be a breaking change: currently a constant const C: Result<i32, f32> = Ok(0) would participate in exhaustiveness checking I think; under the proposed alternative it would not.

@RalfJung RalfJung added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 29, 2023
@RalfJung
Copy link
Member Author

Marking as blocked on rust-lang/lang-team#220.

@bors
Copy link
Contributor

bors commented Sep 29, 2023

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

@RalfJung
Copy link
Member Author

rust-lang/rfcs#3535 motivates why we don't need the StructuralEq trait any more.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 13, 2024

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

@RalfJung
Copy link
Member Author

@lcnr @cjgillot with rust-lang/rfcs#3535 having been accepted, I think this should be ready to go?

@RalfJung RalfJung added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Jan 24, 2024
@lcnr
Copy link
Contributor

lcnr commented Jan 25, 2024

r? @lcnr

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Jan 25, 2024

📌 Commit 0df7810 has been approved by lcnr

It is now in the queue for this repository.

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 25, 2024
remove StructuralEq trait

The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more.

One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust rust-lang#115893 to check for `Eq`, and rule out float matching for good.

Fixes rust-lang#115881
@bors
Copy link
Contributor

bors commented Jan 25, 2024

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 25, 2024
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@RalfJung
Copy link
Member Author

@bors retry timeout

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 25, 2024
@bors
Copy link
Contributor

bors commented Jan 25, 2024

⌛ Testing commit 0df7810 with merge e89fdc4...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 25, 2024
remove StructuralEq trait

The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more.

One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust rust-lang#115893 to check for `Eq`, and rule out float matching for good.

Fixes rust-lang#115881
@bors
Copy link
Contributor

bors commented Jan 25, 2024

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 25, 2024
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@RalfJung
Copy link
Member Author

@bors retry timeout
we are seeing quite a few of these recently...

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 25, 2024
@bors
Copy link
Contributor

bors commented Jan 26, 2024

⌛ Testing commit 0df7810 with merge dd2559e...

@bors
Copy link
Contributor

bors commented Jan 26, 2024

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing dd2559e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 26, 2024
@bors bors merged commit dd2559e into rust-lang:master Jan 26, 2024
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 26, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (dd2559e): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.6%, -0.2%] 48
Improvements ✅
(secondary)
-1.3% [-3.0%, -0.3%] 23
All ❌✅ (primary) -0.4% [-0.6%, 0.3%] 49

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
-2.9% [-5.2%, -0.7%] 2
Improvements ✅
(secondary)
-2.7% [-4.0%, -1.3%] 8
All ❌✅ (primary) -2.9% [-5.2%, -0.7%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-3.3%, -1.3%] 8
All ❌✅ (primary) - - 0

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.2%, -0.0%] 30
Improvements ✅
(secondary)
-1.3% [-2.3%, -0.0%] 10
All ❌✅ (primary) -0.1% [-0.2%, -0.0%] 30

Bootstrap: 662.586s -> 663.451s (0.13%)
Artifact size: 308.16 MiB -> 308.15 MiB (-0.00%)

@RalfJung RalfJung deleted the structural-eq branch January 26, 2024 06:43
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 8, 2024
remove StructuralEq trait

The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more.

One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust rust-lang#115893 to check for `Eq`, and rule out float matching for good.

Fixes rust-lang#115881
GuillaumeGomez pushed a commit to GuillaumeGomez/rust that referenced this pull request Feb 21, 2024
remove StructuralEq trait

The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more.

One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust rust-lang#115893 to check for `Eq`, and rule out float matching for good.

Fixes rust-lang#115881
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Mar 8, 2024
remove StructuralEq trait

The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more.

One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust rust-lang#115893 to check for `Eq`, and rule out float matching for good.

Fixes rust-lang#115881
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StructuralEq trait docs are outdated
8 participants