diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-04 10:42:17 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-04 10:42:17 +0100 |
commit | 4912cc35afe96b1506e5cda1be34d3e2418bc702 (patch) | |
tree | fa40d55d943e18ce52ea072cc26c74fcf519f911 /crates/ra_hir/src/ty/method_resolution.rs | |
parent | 658382c1f5d27813daf93495f4cbd5aada1f0567 (diff) | |
parent | 9f9c5aa65914763f5a9ff80230544fea48cbcdf1 (diff) |
Merge #1634
1634: Implement .await completion for futures r=flodiebold a=eupn
Closes #1263 with completion for `.await` syntax for types that are implementing `std::future::Future` trait.
r? @flodiebold
Co-authored-by: Evgenii P <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/method_resolution.rs')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index d421bf9ef..88d012a74 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -255,6 +255,20 @@ fn iterate_inherent_methods<T>( | |||
255 | None | 255 | None |
256 | } | 256 | } |
257 | 257 | ||
258 | pub(crate) fn implements_trait( | ||
259 | ty: &Canonical<Ty>, | ||
260 | db: &impl HirDatabase, | ||
261 | resolver: &Resolver, | ||
262 | krate: Crate, | ||
263 | trait_: Trait, | ||
264 | ) -> bool { | ||
265 | let env = lower::trait_env(db, resolver); | ||
266 | let goal = generic_implements_goal(db, env.clone(), trait_, ty.clone()); | ||
267 | let solution = db.trait_solve(krate, goal); | ||
268 | |||
269 | solution.is_some() | ||
270 | } | ||
271 | |||
258 | impl Ty { | 272 | impl Ty { |
259 | // This would be nicer if it just returned an iterator, but that runs into | 273 | // This would be nicer if it just returned an iterator, but that runs into |
260 | // lifetime problems, because we need to borrow temp `CrateImplBlocks`. | 274 | // lifetime problems, because we need to borrow temp `CrateImplBlocks`. |