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

Refactor item_name method to use ItemInfo struct #3129

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

twizmwazin
Copy link

Currently, only the name as a &str is passed, which has the limitation that you cannot differentiate between functions and other types. An example use case of this is if you wanted to rename Structs/Unions/Enums to use PascalCase but rename functions to use snake_case, to better follow Rust's conventions.

Fixes #2736

@twizmwazin twizmwazin force-pushed the pass-item-info-to-item-name branch from 6dbc697 to 27b6d79 Compare February 13, 2025 18:39
crate::callbacks::ItemKind::Function
}
_ => crate::callbacks::ItemKind::Var,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct? There are no tests for this but reporting everything that isn't a function a Var seems totally wrong.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, it isn't really correct. It looks like the ir ItemKind type has 4 variants, while the callback ItemKind type has only 2. Modules and Types are the variants missing, I'll add those to the callback enum so that they can be correctly handled.

@twizmwazin twizmwazin requested a review from emilio February 19, 2025 00:10
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.

Pass the kind of item to ParseCallbacks::item_name
2 participants