Bootstrap derive(PartialEq) (#163)#473
Merged
Merged
Conversation
Collaborator
Author
|
I plan to add more features in the follow-up PRs:
|
3 tasks
tyranron
added a commit
that referenced
this pull request
May 27, 2025
Revealed from #473 ## Synopsis `utils::GenericsSearch` doesn't consider associative type, leading to missing trait bounds in `AsRef`/`AsMut` expansions. ```rust #[derive(AsRef)] #[as_ref(forward)] struct Forward<T: Some> { first: T::Assoc, } ``` expands as: ```rust #[allow(deprecated)] #[allow(unreachable_code)] #[automatically_derived] impl<T: Some, __AsT: ?derive_more::core::marker::Sized> derive_more::core::convert::AsRef<__AsT> for Forward<T> { #[inline] fn as_ref(&self) -> &__AsT { <T::Assoc as derive_more::core::convert::AsRef<__AsT>>::as_ref(&self.first) } } ``` but should expand as: ```rust #[allow(deprecated)] #[allow(unreachable_code)] #[automatically_derived] impl<T: Some, __AsT: ?derive_more::core::marker::Sized> derive_more::core::convert::AsRef<__AsT> for Forward<T> where T::Assoc: derive_more::core::convert::AsRef<__AsT>, { #[inline] fn as_ref(&self) -> &__AsT { <T::Assoc as derive_more::core::convert::AsRef<__AsT>>::as_ref(&self.first) } } ``` ## Solution This PR fixes this situation and covers associative types usage in `AsRef`/`AsMut` tests. ## Additionally Improves `utils::GenericsSearch` performance by early returns (stop `Visit`ing whenever something is found). Also, unit tests for `utils::GenericsSearch` are added.
Collaborator
Author
|
@JelteF note: I named Cargo feature
|
3 tasks
Collaborator
Author
|
ping @JelteF |
JelteF
approved these changes
May 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #163
Synopsis
This PR is the initial part of #163 and adds only structural expansion of
derive(PartialEq).Solution
Mirrors the
PartialEqexpansion ofstd, but applies trait bounds for generics correctly.Checklist