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

Fix transparency for top-level shared attribute in Display #438

Merged
merged 5 commits into from
Jan 18, 2025

Conversation

tyranron
Copy link
Collaborator

@tyranron tyranron commented Jan 16, 2025

Synopsis

The transparency is not considered when the top-level shared #[display(...)] attribute on enum uses a field directly.

#[derive(Display)]
#[display("{_0}")]
enum Foo<A> {
    A(A),
}

assert_eq!(format!("{:03}", Foo::<i8>::A(7)), "007");

results in:

assertion `left == right` failed
  left: "7"
 right: "007"

Solution

Consider field's transparency for the top-level shared #[display(...)] attribute.

Checklist

  • Documentation is updated (not required)
  • Tests are added/updated
  • CHANGELOG entry is added

@tyranron tyranron added this to the 2.0.0 milestone Jan 16, 2025
@tyranron tyranron self-assigned this Jan 16, 2025
@tyranron tyranron marked this pull request as ready for review January 16, 2025 13:27
@tyranron tyranron enabled auto-merge (squash) January 16, 2025 13:29
@tyranron tyranron requested a review from JelteF January 16, 2025 13:29
@tyranron tyranron merged commit d391493 into master Jan 18, 2025
17 checks passed
@tyranron tyranron deleted the fix-fmt-transparency branch January 18, 2025 00:18
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.

2 participants