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

@@ -369,6 +369,17 @@ impl SourceAnalyzer {
)
}
pub fn autoderef<'a>(
&'a self,
db: &'a impl HirDatabase,
ty: Ty,
) -> impl Iterator<Item = Ty> + 'a {
// There should be no inference vars in types passed here
// FIXME check that?
let canonical = crate::ty::Canonical { value: ty, num_vars: 0 };
crate::ty::autoderef(db, &self.resolver, canonical).map(|canonical| canonical.value)
}
#[cfg(test)]
pub(crate) fn body_source_map(&self) -> Arc<BodySourceMap> {
self.body_source_map.clone().unwrap()