mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
internal: Handle fields called as method calls as the fields they resolve to
This commit is contained in:
parent
b85e2af898
commit
5a91f015b4
4 changed files with 63 additions and 4 deletions
|
@ -10,6 +10,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
body::{
|
||||
self,
|
||||
|
@ -266,6 +267,21 @@ impl SourceAnalyzer {
|
|||
Some(self.resolve_impl_method_or_trait_def(db, f_in_trait, substs))
|
||||
}
|
||||
|
||||
pub(crate) fn resolve_method_call_fallback(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
call: &ast::MethodCallExpr,
|
||||
) -> Option<Either<FunctionId, FieldId>> {
|
||||
let expr_id = self.expr_id(db, &call.clone().into())?;
|
||||
let inference_result = self.infer.as_ref()?;
|
||||
match inference_result.method_resolution(expr_id) {
|
||||
Some((f_in_trait, substs)) => {
|
||||
Some(Either::Left(self.resolve_impl_method_or_trait_def(db, f_in_trait, substs)))
|
||||
}
|
||||
None => inference_result.field_resolution(expr_id).map(Either::Right),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn resolve_await_to_poll(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue