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

feat: Complete derive helper attributes #18604

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

ChayimFriedman2
Copy link
Contributor

Only their names, anything can go inside.

Closes #18588.

This only completes when you type the first letter, I don't know why...

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 3, 2024
crates/ide-completion/src/completions/attribute.rs Outdated Show resolved Hide resolved
Comment on lines +1132 to +1143
let derive_helpers = annotated_item_kind
.filter(|kind| {
matches!(
kind,
SyntaxKind::STRUCT
| SyntaxKind::ENUM
| SyntaxKind::UNION
| SyntaxKind::VARIANT
| SyntaxKind::TUPLE_FIELD
| SyntaxKind::RECORD_FIELD
)
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be used within the type specifications within ADTs as well, as in struct T { field: fn(#[helper] ()) } if I am not mistaken, though this is good enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked and that's not true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
It does work, but no one ever does this. rustfmt even drops the attribute in the function pointer param. So either way this is good enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I thought you mean the opposite - that the attribute is not a helper but completed as such.

@Veykril
Copy link
Member

Veykril commented Dec 4, 2024

This only completes when you type the first letter, I don't know why...

Empty attributes have a broken parse tree, so thats likely why
#[] yields:

#18608 will fix that

Only their names, anything can go inside.
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril enabled auto-merge December 4, 2024 06:31
@Veykril Veykril added this pull request to the merge queue Dec 4, 2024
Merged via the queue into rust-lang:master with commit 99c9a99 Dec 4, 2024
9 checks passed
@ChayimFriedman2 ChayimFriedman2 deleted the complete-helpers branch December 9, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Completions for derive macro helper attributes
3 participants