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

Don't impl PartialEq/Eq for SharedReference and wrapper types #8815

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bgw
Copy link
Member

@bgw bgw commented Jul 23, 2024

Description

Where feasible (I gave up on TransientInstance<T>) don't impl PartialEq, Eq or Hash for SharedReference or it's various wrapper types.

These were previously using identity for equality, but I strongly prefer a more explicit approach (akin to Arc::ptr_eq) when using identity equality because it can lead to caching bugs where the caller didn't realize and expected value equality.

Testing Instructions

This breaks the nextjs build and would require a companion nextjs PR if we wanted to go forward with this.

Copy link

vercel bot commented Jul 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2024 4:59am
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2024 4:59am
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 4:59am
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 4:59am
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 4:59am
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 4:59am
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 4:59am
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 4:59am
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 4:59am
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 4:59am

Copy link
Member Author

bgw commented Jul 23, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @bgw and the rest of your teammates on Graphite Graphite

Copy link
Contributor

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

⚠️ This change may fail to build next-swc.

Logs

crates/next-core/src/next_telemetry.rs:42:9: �[38;5;9merror[E0271]: type mismatch resolving `<DiagnosticPayload as VcValueType>::Read == VcTransparentRead<DiagnosticPayload, HashMap<RcStr, _>, _>`
crates/next-core/src/next_telemetry.rs:82:9: �[38;5;9merror[E0271]: type mismatch resolving `<DiagnosticPayload as VcValueType>::Read == VcTransparentRead<DiagnosticPayload, HashMap<RcStr, _>, _>`
error: could not compile `next-core` (lib) due to 2 previous errors

See job summary for details

Copy link
Contributor

github-actions bot commented Jul 23, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (linux)
  • Turbopack Rust tests (mac/win, non-blocking)
  • Turbopack Rust benchmark tests (linux)
  • Turbopack Rust benchmark tests (mac/win, non-blocking)

See workflow summary for details

fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.inner.hash(state);
self.inner.1.as_ptr().hash(state);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe implement ptr_hash on SharedReference

Comment on lines +32 to +33
this.iter()
.all(|(key, value)| other.get(key).map_or(false, |v| value.ptr_eq(v)))
Copy link
Member

Choose a reason for hiding this comment

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

Order should matter here. You can use zip() instead. That's also more performant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants