-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: auto-completion for associated type constants #19118
base: master
Are you sure you want to change the base?
Conversation
}; | ||
|
||
let impl_data = db.type_alias_data(impl_type_alias_id); | ||
if impl_data.name.as_str() == "Assoc" { |
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.
I am sure there is a better way to do this check but was having a hard time figuring it out. Open to any suggestions but wanted to get eyes on this change to make sure this was the ideal way to solve
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.
It feels very wrong to change analysis (which is working properly) in order to solve this. You're also duplicating a bunch of work here, slowing down analysis, and this has other disadvantages too (like creating a query dependency to trait_impls_in_crate()
and a bunch of others).
In general, solving traits and normalizing associated types (that's how we call the process of determining what actual type an associated type has) is the job of the trait solver. In our case, it's Chalk. It can easily find the relevant impls, and normalize the associated type. I don't know why completion isn't using it, but this is what it should do. If you need any pointers/help don't hesitate to ask!
Thanks anyway for your efforts!
} | ||
impl PersonPaths { | ||
pub const NAME: &'static str = "name"; | ||
pub fn get_default() -> String { String::new() } |
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.
String
isn't available in our tests (that's why you have {unknown}
), you can use primitive types like i32
or &str
.
Not a problem at all! I can close the PR and solve using chalk. I figured there was a better place to solve. Thanks for the info! |
There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged. You can start a rebase with the following commands:
The following commits are merge commits: |
This commit fixes an issue where rust-analyzer failed to resolve and auto-complete constants defined inside associated types.
Changes:
type_for_type_alias_with_diagnostics_query
to resolve trait-associated types to their implementing type alias.Resolves #18935.