-
Notifications
You must be signed in to change notification settings - Fork 124
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
Only put Display-like bounds on type variables #387
Merged
Merged
Conversation
This file contains 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
JelteF
force-pushed
the
fix-display-bounds
branch
5 times, most recently
from
July 20, 2024 11:46
01c60d2
to
5f602fe
Compare
JelteF
force-pushed
the
fix-display-bounds
branch
from
July 20, 2024 11:47
5f602fe
to
23da4e6
Compare
JelteF
force-pushed
the
fix-display-bounds
branch
2 times, most recently
from
July 24, 2024 22:11
b658620
to
4f92982
Compare
JelteF
force-pushed
the
fix-display-bounds
branch
from
July 24, 2024 22:17
4f92982
to
ba743ea
Compare
# Conflicts: # impl/doc/display.md # impl/src/fmt/display.rs # tests/display.rs
tyranron
approved these changes
Jul 25, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JelteF this seems fine. The only change I've added is extracting the duplicate code of syn::Type
/syn::Path
traversal to the fmt
module shared by both expansions.
3 tasks
tyranron
added a commit
that referenced
this pull request
Aug 20, 2024
Related to #387 ## Synopsis After #387, the following snippet fails to compile: ```rust #[derive(Debug)] struct AssocType<I: Iterator> { iter: I, elem: Option<I::Item>, } ``` This happens, because the implied bound `Option<I::Item>: Debug` is not generated. ## Solution Correct the `ContainsGenericsExt::contains_generics()` implementations to consider associated types of the type parameter.
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.
Only put Display-like bounds on type variables
Resolves #363
Requires #377
Related to #371
Synopsis
The problem is that the
Display
derive adds a bounds for all types thatare used in the format string. But this is not necessary for types that
don't contain a type variable. And adding those bounds can result in
errors like for the following code:
That code would generate the following error:
Solution
This makes sure we don't add unnecessary bounds for Display-like
derives. It does so in the same way as #371 did for the Debug derive: By
only adding bounds when the type contains a type variable.
Checklist
Changelog is not updated because the 0.99 did not have this issue.