Implement autoderef using the Deref trait

- add support for other lang item targets, since we need the Deref lang item
This commit is contained in:
Florian Diebold 2019-05-12 18:33:47 +02:00
parent 49489dc20c
commit 9c5e7dd849
11 changed files with 153 additions and 48 deletions

View file

@ -15,7 +15,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
}
fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) {
for receiver in receiver.autoderef(ctx.db) {
for receiver in ctx.analyzer.autoderef(ctx.db, receiver) {
if let Ty::Apply(a_ty) = receiver {
match a_ty.ctor {
TypeCtor::Adt(AdtDef::Struct(s)) => {

View file

@ -30,7 +30,7 @@ pub(crate) fn goto_type_definition(
return None;
};
let adt_def = ty.autoderef(db).find_map(|ty| ty.as_adt().map(|adt| adt.0))?;
let adt_def = analyzer.autoderef(db, ty).find_map(|ty| ty.as_adt().map(|adt| adt.0))?;
let nav = NavigationTarget::from_adt_def(db, adt_def);
Some(RangeInfo::new(node.range(), vec![nav]))