Diagnose unresolved method calls

This commit is contained in:
Lukas Wirth 2023-03-03 20:41:17 +01:00
parent 78b2dd813a
commit e7485a0416
8 changed files with 320 additions and 48 deletions

View file

@ -89,7 +89,7 @@ pub use crate::{
MissingMatchArms, MissingUnsafe, NoSuchField, PrivateAssocItem, PrivateField,
ReplaceFilterMapNextWithFindMap, TypeMismatch, UnimplementedBuiltinMacro,
UnresolvedExternCrate, UnresolvedField, UnresolvedImport, UnresolvedMacroCall,
UnresolvedModule, UnresolvedProcMacro,
UnresolvedMethodCall, UnresolvedModule, UnresolvedProcMacro,
},
has_source::HasSource,
semantics::{PathResolution, Semantics, SemanticsScope, TypeInfo, VisibleTraits},
@ -1441,6 +1441,26 @@ impl DefWithBody {
.into(),
)
}
hir_ty::InferenceDiagnostic::UnresolvedMethodCall {
expr,
receiver,
name,
field_with_same_name,
} => {
let expr = expr_syntax(*expr);
acc.push(
UnresolvedMethodCall {
expr,
name: name.clone(),
receiver: Type::new(db, DefWithBodyId::from(self), receiver.clone()),
field_with_same_name: field_with_same_name
.clone()
.map(|ty| Type::new(db, DefWithBodyId::from(self), ty)),
}
.into(),
)
}
}
}
for (pat_or_expr, mismatch) in infer.type_mismatches() {