From 251ef93ac3bbb138a2eedf6090f2f56f1a15d898 Mon Sep 17 00:00:00 2001 From: oxalica Date: Thu, 10 Sep 2020 20:01:23 +0800 Subject: Implement async blocks --- crates/ide/src/completion/complete_keyword.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/ide/src') diff --git a/crates/ide/src/completion/complete_keyword.rs b/crates/ide/src/completion/complete_keyword.rs index 53ba76e0e..5645b41fa 100644 --- a/crates/ide/src/completion/complete_keyword.rs +++ b/crates/ide/src/completion/complete_keyword.rs @@ -506,6 +506,28 @@ pub mod future { #[lang = "future_trait"] pub trait Future {} } +"#, + expect![[r#" + kw await expr.await + "#]], + ); + + check( + r#" +//- /main.rs +use std::future::*; +fn foo() { + let a = async {}; + a.<|> +} + +//- /std/lib.rs +pub mod future { + #[lang = "future_trait"] + pub trait Future { + type Output; + } +} "#, expect![[r#" kw await expr.await -- cgit v1.2.3 From 529c369c9bc15a73e7a03260eca84ccef99ac281 Mon Sep 17 00:00:00 2001 From: oxalica Date: Sat, 12 Sep 2020 01:03:28 +0800 Subject: Fix type walking about type of async block --- crates/ide/src/hover.rs | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'crates/ide/src') diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index efec0184e..37171cbef 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -2646,6 +2646,70 @@ fn foo(ar<|>g: &impl Foo + Bar) {} ); } + #[test] + fn test_hover_async_block_impl_trait_has_goto_type_action() { + check_actions( + r#" +struct S; +fn foo() { + let fo<|>o = async { S }; +} + +#[prelude_import] use future::*; +mod future { + #[lang = "future_trait"] + pub trait Future { type Output; } +} +"#, + expect![[r#" + [ + GoToType( + [ + HoverGotoTypeData { + mod_path: "test::future::Future", + nav: NavigationTarget { + file_id: FileId( + 1, + ), + full_range: 101..163, + focus_range: Some( + 140..146, + ), + name: "Future", + kind: TRAIT, + container_name: None, + description: Some( + "pub trait Future", + ), + docs: None, + }, + }, + HoverGotoTypeData { + mod_path: "test::S", + nav: NavigationTarget { + file_id: FileId( + 1, + ), + full_range: 0..9, + focus_range: Some( + 7..8, + ), + name: "S", + kind: STRUCT, + container_name: None, + description: Some( + "struct S", + ), + docs: None, + }, + }, + ], + ), + ] + "#]], + ); + } + #[test] fn test_hover_arg_generic_impl_trait_has_goto_type_action() { check_actions( -- cgit v1.2.3