diff options
author | Evgenii P <[email protected]> | 2019-08-02 19:53:51 +0100 |
---|---|---|
committer | Evgenii P <[email protected]> | 2019-08-02 19:53:51 +0100 |
commit | ab7774545cb5e45064c907429417bdee8d89f4d4 (patch) | |
tree | 21642a3ffe5cf19191513609c0e09bdc90ca9777 /crates/ra_ide_api/src | |
parent | 30bc3b93bec06256350b66869f2885ee71c3bedd (diff) |
Use future lang item instead of hardcoded std::future::Future
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 1dbbdb1bc..93e5d816d 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -37,7 +37,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { | |||
37 | } | 37 | } |
38 | complete_methods(acc, ctx, receiver_ty.clone()); | 38 | complete_methods(acc, ctx, receiver_ty.clone()); |
39 | 39 | ||
40 | // Suggest .await syntax for types that implement std::future::Future | 40 | // Suggest .await syntax for types that implement Future trait |
41 | if ctx.analyzer.impls_future(ctx.db, receiver_ty) { | 41 | if ctx.analyzer.impls_future(ctx.db, receiver_ty) { |
42 | postfix_reference(ctx, ".await", "expr.await", &format!("{}.await", receiver_text)) | 42 | postfix_reference(ctx, ".await", "expr.await", &format!("{}.await", receiver_text)) |
43 | .add_to(acc); | 43 | .add_to(acc); |
@@ -441,9 +441,14 @@ mod tests { | |||
441 | fn test_completion_await_impls_future() { | 441 | fn test_completion_await_impls_future() { |
442 | assert_debug_snapshot_matches!( | 442 | assert_debug_snapshot_matches!( |
443 | do_ref_completion( | 443 | do_ref_completion( |
444 | r" | 444 | r###" |
445 | // Mock Future trait from stdlib | 445 | // Mock Future trait from stdlib |
446 | pub mod std { pub mod future { pub trait Future {} } } | 446 | pub mod std { |
447 | pub mod future { | ||
448 | #[lang = "future_trait"] | ||
449 | pub trait Future {} | ||
450 | } | ||
451 | } | ||
447 | 452 | ||
448 | use std::future::*; | 453 | use std::future::*; |
449 | struct A {} | 454 | struct A {} |
@@ -452,13 +457,13 @@ mod tests { | |||
452 | fn foo(a: A) { | 457 | fn foo(a: A) { |
453 | a.<|> | 458 | a.<|> |
454 | } | 459 | } |
455 | "), | 460 | "###), |
456 | @r###" | 461 | @r###" |
457 | ⋮[ | 462 | ⋮[ |
458 | ⋮ CompletionItem { | 463 | ⋮ CompletionItem { |
459 | ⋮ label: ".await", | 464 | ⋮ label: ".await", |
460 | ⋮ source_range: [249; 249), | 465 | ⋮ source_range: [358; 358), |
461 | ⋮ delete: [247; 249), | 466 | ⋮ delete: [356; 358), |
462 | ⋮ insert: "a.await", | 467 | ⋮ insert: "a.await", |
463 | ⋮ detail: "expr.await", | 468 | ⋮ detail: "expr.await", |
464 | ⋮ }, | 469 | ⋮ }, |