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 order sensitivity of Display attributes (#319) #320

Merged
merged 3 commits into from
Dec 11, 2023

Conversation

tyranron
Copy link
Collaborator

@tyranron tyranron commented Dec 5, 2023

Resolves #319

Synopsis

See #319 (comment):

The following code used to work in 1.0.0-beta.3:

#[derive(Display)]
#[display("{name}@{tag}")]
#[display(bound(Tag: std::fmt::Display))]
struct Specifier<Tag> {
    name: String,
    tag: Tag,
}

However, in 1.0.0-beta.6, it emits the following error message:

error: multiple `#[display("...", ...)]` attributes aren't allowed

It took me a long time to figure out that the fix was to swap place between the 2 display attributes.

The regression lies here, where mem::replace doesn't provide the implied and expected "and" logic for merging two Options.

Solution

  • Merge those two Options correctly.
  • Recheck similar places over the code.

Checklist

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

@tyranron tyranron added this to the 1.0.0 milestone Dec 5, 2023
@tyranron tyranron self-assigned this Dec 5, 2023
@tyranron tyranron marked this pull request as ready for review December 5, 2023 13:16
@tyranron tyranron requested a review from JelteF December 5, 2023 13:16
@tyranron tyranron merged commit 1536f52 into master Dec 11, 2023
16 checks passed
@tyranron tyranron deleted the 319-fix-attrs-order branch December 11, 2023 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.0.0-beta.6] Specifying Display trait bound after format causes confusing error message.
2 participants