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

Disallow mutable generics in hashing collections #507

Closed
madsmtm opened this issue Sep 10, 2023 · 3 comments · Fixed by #626
Closed

Disallow mutable generics in hashing collections #507

madsmtm opened this issue Sep 10, 2023 · 3 comments · Fixed by #626
Labels
A-framework Affects the framework crates and the translator for them I-unsound A soundness hole

Comments

@madsmtm
Copy link
Owner

madsmtm commented Sep 10, 2023

Continuation of #337, in #505 we restricted the key types to HasStableHash types, but types like NSArray<NSView> are still incorrectly considered stably hashable.

@madsmtm madsmtm added A-framework Affects the framework crates and the translator for them I-unsound A soundness hole labels Sep 10, 2023
@madsmtm
Copy link
Owner Author

madsmtm commented Sep 10, 2023

Maybe we should just make HasStableHash a manual trait, instead of having it be implemented automatically based on ClassType::Mutability?

@madsmtm
Copy link
Owner Author

madsmtm commented Sep 10, 2023

Also somewhat related to #474, where we also have to have special behaviour for generic types.

@madsmtm
Copy link
Owner Author

madsmtm commented Jan 16, 2024

I looked at the classes in Apple's frameworks that is used as the T inside NSSet<T> or the K inside NSDictionary<K, V>; it's a non-trivial amount of things (even if we discount type-aliases to NSString), so I think we have to do this automatically.

Maybe an approach could be to generate implementations based on whether the type is used anywhere as such? Since that's very strong evidence that the type is valid to use in a hashing collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them I-unsound A soundness hole
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant