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 legacy diagnostic for Display-like macros #288

Merged
merged 3 commits into from
Aug 9, 2023

Conversation

tyranron
Copy link
Collaborator

@tyranron tyranron commented Aug 9, 2023

Related to #225

Synopsis

Diagnostic introduced in #225 regarding old syntax usage, displays incorrect message in case formatting arguments are specified as identifiers (not string literals):

#[derive(derive_more::Display)]
#[display(fmt = "Stuff({}): {}", _0)]
pub struct Bar(String);
error: unknown attribute, expected `bound(...)`
 --> tests/compile_fail/display/legacy_fmt_syntax.rs:8:11
  |
8 | #[display(fmt = "Stuff({}): {}", _0)]
  |           ^^^

In my experience, this situation happens very often in the wild.

Solution

Fix the diagnostic to consider ident formatting arguments properly.

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 Aug 9, 2023
@tyranron tyranron self-assigned this Aug 9, 2023
@tyranron tyranron marked this pull request as draft August 9, 2023 14:49
@tyranron tyranron marked this pull request as ready for review August 9, 2023 15:11
@tyranron tyranron requested a review from JelteF August 9, 2023 15:17
@JelteF JelteF merged commit df771b4 into master Aug 9, 2023
16 checks passed
@JelteF JelteF deleted the fix-display-legacy-diagnostic branch August 9, 2023 21:38
@tyranron tyranron mentioned this pull request Aug 10, 2023
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.

None yet

2 participants