-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add static modifier for associated functions
#6472
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
Conversation
…self refactor logic into code_model.rs
crates/hir/src/code_model.rs
Outdated
|
|
||
| /// whether this function is associated with some trait/impl | ||
| pub fn is_associated(self, db: &dyn HirDatabase) -> bool { | ||
| if let Some(_) = self.self_param(db) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be
if self.self_param(db).is_some()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 👍
…self refactor logic into code_model.rs
…self refactor logic into code_model.rs address comments
| if func.is_unsafe(db) { | ||
| h |= HighlightModifier::Unsafe; | ||
| } | ||
| if func.is_associated(db) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use something like this instead:
| if func.is_associated(db) { | |
| if func.is_assoc_item(db) && func.self_param(db).is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh dear, that was one confusing comment, sorry.
What I meant to say is that we already have as_assoc_item function we can use here, instead of implementing a new is_assoc_item:
…self refactor logic into code_model.rs address comments
…self refactor logic into code_model.rs address comments
|
bors r+ Thanks! |
|
Thanks for accepting! |
Adds static semantic token modifier to associated functions, resolves #6194
Info
Changes
is_associatedto code_model::Function. This basically gets the source from the ast, and checks whether the enclosing scope is an impl or trait.staticto HighlightModifiersTests
cargo test