diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-16 13:00:41 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-16 13:00:41 +0100 |
commit | b81caed43f1886024ededad41a1baa8a03f1d2f4 (patch) | |
tree | 0a0289899ec59b425eae6369929a01e97065ce43 /crates/ra_hir/src/source_binder.rs | |
parent | e6fbff3246cdd3278ff1c376d5abfc1d579f86c2 (diff) | |
parent | ad3673d8d86a9b8f1a8dba858abd7cabaa1d5776 (diff) |
Merge #1408
1408: Associated type basics & Deref support r=matklad a=flodiebold
This adds the necessary Chalk integration to handle associated types and uses it to implement support for `Deref` in the `*` operator and autoderef; so e.g. dot completions through an `Arc` work now.
It doesn't yet implement resolution of associated types in paths, though. Also, there's a big FIXME about handling variables in the solution we get from Chalk correctly.
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 4f9e8c5a9..08e86844d 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -369,6 +369,17 @@ impl SourceAnalyzer { | |||
369 | ) | 369 | ) |
370 | } | 370 | } |
371 | 371 | ||
372 | pub fn autoderef<'a>( | ||
373 | &'a self, | ||
374 | db: &'a impl HirDatabase, | ||
375 | ty: Ty, | ||
376 | ) -> impl Iterator<Item = Ty> + 'a { | ||
377 | // There should be no inference vars in types passed here | ||
378 | // FIXME check that? | ||
379 | let canonical = crate::ty::Canonical { value: ty, num_vars: 0 }; | ||
380 | crate::ty::autoderef(db, &self.resolver, canonical).map(|canonical| canonical.value) | ||
381 | } | ||
382 | |||
372 | #[cfg(test)] | 383 | #[cfg(test)] |
373 | pub(crate) fn body_source_map(&self) -> Arc<BodySourceMap> { | 384 | pub(crate) fn body_source_map(&self) -> Arc<BodySourceMap> { |
374 | self.body_source_map.clone().unwrap() | 385 | self.body_source_map.clone().unwrap() |