From dc4876d33dc9713507a40569c01c6c335515f376 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 23 Jun 2021 18:37:47 +0200 Subject: [PATCH 1/4] Lift out base item fixture for ide_completion tests --- crates/ide_completion/src/tests.rs | 16 ++++++ crates/ide_completion/src/tests/item_list.rs | 54 +++++++------------ crates/ide_completion/src/tests/items.rs | 40 ++++++-------- crates/ide_completion/src/tests/pattern.rs | 18 ++----- crates/ide_completion/src/tests/use_tree.rs | 1 + .../ide_completion/src/tests/where_clause.rs | 12 +++++ 6 files changed, 68 insertions(+), 73 deletions(-) create mode 100644 crates/ide_completion/src/tests/where_clause.rs diff --git a/crates/ide_completion/src/tests.rs b/crates/ide_completion/src/tests.rs index 97298ff27d0..12008cf59c1 100644 --- a/crates/ide_completion/src/tests.rs +++ b/crates/ide_completion/src/tests.rs @@ -9,6 +9,7 @@ mod use_tree; mod items; mod pattern; mod type_pos; +mod where_clause; use std::mem; @@ -28,6 +29,21 @@ use test_utils::assert_eq_text; use crate::{item::CompletionKind, CompletionConfig, CompletionItem}; +/// Lots of basic item definitions +const BASE_FIXTURE: &str = r#" +enum Enum { TupleV(u32), RecordV { field: u32 }, UnitV } +use self::Enum::TupleV; +mod module {} + +trait Trait {} +static STATIC: Unit = Unit; +const CONST: Unit = Unit; +struct Record { field: u32 } +struct Tuple(u32); +struct Unit +macro_rules! makro {} +"#; + pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig { enable_postfix_completions: true, enable_imports_on_the_fly: true, diff --git a/crates/ide_completion/src/tests/item_list.rs b/crates/ide_completion/src/tests/item_list.rs index 7c124ac370b..ae71adf8e00 100644 --- a/crates/ide_completion/src/tests/item_list.rs +++ b/crates/ide_completion/src/tests/item_list.rs @@ -1,19 +1,9 @@ use expect_test::{expect, Expect}; -use crate::tests::completion_list; +use crate::tests::{completion_list, BASE_FIXTURE}; fn check(ra_fixture: &str, expect: Expect) { - let base = r#"#[rustc_builtin_macro] -pub macro Clone {} -enum Enum { Variant } -struct Struct {} -#[macro_export] -macro_rules! foo {} -mod bar {} -const CONST: () = (); -trait Trait {} -"#; - let actual = completion_list(&format!("{}{}", base, ra_fixture)); + let actual = completion_list(&format!("{}{}", BASE_FIXTURE, ra_fixture)); expect.assert_eq(&actual) } @@ -21,7 +11,7 @@ trait Trait {} fn in_mod_item_list() { check( r#"mod tests { $0 }"#, - expect![[r##" + expect![[r#" kw pub(crate) kw pub kw unsafe @@ -40,8 +30,8 @@ fn in_mod_item_list() { sn tmod (Test module) sn tfn (Test function) sn macro_rules - ma foo!(…) #[macro_export] macro_rules! foo - "##]], + ma makro!(…) macro_rules! makro + "#]], ) } @@ -49,7 +39,7 @@ fn in_mod_item_list() { fn in_source_file_item_list() { check( r#"$0"#, - expect![[r##" + expect![[r#" kw pub(crate) kw pub kw unsafe @@ -68,10 +58,9 @@ fn in_source_file_item_list() { sn tmod (Test module) sn tfn (Test function) sn macro_rules - md bar - ma foo!(…) #[macro_export] macro_rules! foo - ma foo!(…) #[macro_export] macro_rules! foo - "##]], + md module + ma makro!(…) macro_rules! makro + "#]], ) } @@ -106,7 +95,7 @@ fn in_item_list_after_attr() { fn in_qualified_path() { check( r#"crate::$0"#, - expect![[r##" + expect![[r#" kw pub(crate) kw pub kw unsafe @@ -122,9 +111,8 @@ fn in_qualified_path() { kw enum kw struct kw union - md bar - ma foo!(…) #[macro_export] macro_rules! foo - "##]], + md module + "#]], ) } @@ -177,17 +165,16 @@ fn after_visibility_unsafe() { fn in_impl_assoc_item_list() { check( r#"impl Struct { $0 }"#, - expect![[r##" + expect![[r#" kw pub(crate) kw pub kw unsafe kw fn kw const kw type - md bar - ma foo!(…) #[macro_export] macro_rules! foo - ma foo!(…) #[macro_export] macro_rules! foo - "##]], + md module + ma makro!(…) macro_rules! makro + "#]], ) } @@ -210,14 +197,13 @@ fn in_impl_assoc_item_list_after_attr() { fn in_trait_assoc_item_list() { check( r"trait Foo { $0 }", - expect![[r##" + expect![[r#" kw unsafe kw fn kw const kw type - md bar - ma foo!(…) #[macro_export] macro_rules! foo - ma foo!(…) #[macro_export] macro_rules! foo - "##]], + md module + ma makro!(…) macro_rules! makro + "#]], ); } diff --git a/crates/ide_completion/src/tests/items.rs b/crates/ide_completion/src/tests/items.rs index b98baffd6ce..5acfdcc85da 100644 --- a/crates/ide_completion/src/tests/items.rs +++ b/crates/ide_completion/src/tests/items.rs @@ -4,20 +4,10 @@ //! in [crate::completions::mod_]. use expect_test::{expect, Expect}; -use crate::tests::completion_list; +use crate::tests::{completion_list, BASE_FIXTURE}; fn check(ra_fixture: &str, expect: Expect) { - let base = r#"#[rustc_builtin_macro] -pub macro Clone {} -enum Enum { Variant } -struct Struct {} -#[macro_export] -macro_rules! foo {} -mod bar {} -const CONST: () = (); -trait Trait {} -"#; - let actual = completion_list(&format!("{}{}", base, ra_fixture)); + let actual = completion_list(&format!("{}{}", BASE_FIXTURE, ra_fixture)); expect.assert_eq(&actual) } @@ -27,15 +17,16 @@ fn target_type_or_trait_in_impl_block() { r#" impl Tra$0 "#, - expect![[r##" + expect![[r#" tt Trait en Enum - st Struct - md bar - ma foo!(…) #[macro_export] macro_rules! foo - ma foo!(…) #[macro_export] macro_rules! foo + st Record + st Tuple + md module + st Unit + ma makro!(…) macro_rules! makro bt u32 - "##]], + "#]], ) } @@ -45,15 +36,16 @@ fn target_type_in_trait_impl_block() { r#" impl Trait for Str$0 "#, - expect![[r##" + expect![[r#" tt Trait en Enum - st Struct - md bar - ma foo!(…) #[macro_export] macro_rules! foo - ma foo!(…) #[macro_export] macro_rules! foo + st Record + st Tuple + md module + st Unit + ma makro!(…) macro_rules! makro bt u32 - "##]], + "#]], ) } diff --git a/crates/ide_completion/src/tests/pattern.rs b/crates/ide_completion/src/tests/pattern.rs index 1ad5ccd97af..48c2fa9aa28 100644 --- a/crates/ide_completion/src/tests/pattern.rs +++ b/crates/ide_completion/src/tests/pattern.rs @@ -1,7 +1,7 @@ //! Completions tests for pattern position. use expect_test::{expect, Expect}; -use crate::tests::completion_list; +use crate::tests::{completion_list, BASE_FIXTURE}; fn check(ra_fixture: &str, expect: Expect) { let actual = completion_list(ra_fixture); @@ -9,19 +9,7 @@ fn check(ra_fixture: &str, expect: Expect) { } fn check_with(ra_fixture: &str, expect: Expect) { - let base = r#" -enum Enum { TupleV(u32), RecordV { field: u32 }, UnitV } -use self::Enum::TupleV; -mod module {} - -static STATIC: Unit = Unit; -const CONST: Unit = Unit; -struct Record { field: u32 } -struct Tuple(u32); -struct Unit -macro_rules! makro {} -"#; - let actual = completion_list(&format!("{}\n{}", base, ra_fixture)); + let actual = completion_list(&format!("{}\n{}", BASE_FIXTURE, ra_fixture)); expect.assert_eq(&actual) } @@ -123,9 +111,9 @@ fn foo() { "#, expect![[r#" kw mut + en Enum bn Record Record { field$1 }$0 st Record - en Enum bn Tuple Tuple($1)$0 st Tuple md module diff --git a/crates/ide_completion/src/tests/use_tree.rs b/crates/ide_completion/src/tests/use_tree.rs index 7e6748cccd2..7ad679f10ea 100644 --- a/crates/ide_completion/src/tests/use_tree.rs +++ b/crates/ide_completion/src/tests/use_tree.rs @@ -1,3 +1,4 @@ +//! Completions tests for use trees. use expect_test::{expect, Expect}; use crate::tests::completion_list; diff --git a/crates/ide_completion/src/tests/where_clause.rs b/crates/ide_completion/src/tests/where_clause.rs new file mode 100644 index 00000000000..0395cbf37a7 --- /dev/null +++ b/crates/ide_completion/src/tests/where_clause.rs @@ -0,0 +1,12 @@ +//! Completion tests for inside of where clauses. +//! +//! The parent of the where clause tends to bleed completions of itself into the where clause so this +//! has to be thoroughly tested. +use expect_test::{expect, Expect}; + +use crate::tests::completion_list; + +fn check(ra_fixture: &str, expect: Expect) { + let actual = completion_list(ra_fixture); + expect.assert_eq(&actual) +} From d4877ae992548fe4b1c756f54dffd614dd0f69e5 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 23 Jun 2021 18:58:19 +0200 Subject: [PATCH 2/4] Add predicate tests for ide_completions --- crates/ide_completion/src/completions/dot.rs | 2 +- crates/ide_completion/src/tests.rs | 2 +- crates/ide_completion/src/tests/predicate.rs | 142 ++++++++++++++++++ .../ide_completion/src/tests/where_clause.rs | 12 -- 4 files changed, 144 insertions(+), 14 deletions(-) create mode 100644 crates/ide_completion/src/tests/predicate.rs delete mode 100644 crates/ide_completion/src/tests/where_clause.rs diff --git a/crates/ide_completion/src/completions/dot.rs b/crates/ide_completion/src/completions/dot.rs index 286d7cb67ca..d9754053470 100644 --- a/crates/ide_completion/src/completions/dot.rs +++ b/crates/ide_completion/src/completions/dot.rs @@ -33,7 +33,7 @@ fn complete_undotted_self(acc: &mut Completions, ctx: &CompletionContext) { if !ctx.config.enable_self_on_the_fly { return; } - if !ctx.is_trivial_path() || ctx.is_path_disallowed() { + if !ctx.is_trivial_path() || ctx.is_path_disallowed() || !ctx.expects_expression() { return; } ctx.scope.process_all_names(&mut |name, def| { diff --git a/crates/ide_completion/src/tests.rs b/crates/ide_completion/src/tests.rs index 12008cf59c1..89faa9526c4 100644 --- a/crates/ide_completion/src/tests.rs +++ b/crates/ide_completion/src/tests.rs @@ -9,7 +9,7 @@ mod use_tree; mod items; mod pattern; mod type_pos; -mod where_clause; +mod predicate; use std::mem; diff --git a/crates/ide_completion/src/tests/predicate.rs b/crates/ide_completion/src/tests/predicate.rs new file mode 100644 index 00000000000..04ff08669df --- /dev/null +++ b/crates/ide_completion/src/tests/predicate.rs @@ -0,0 +1,142 @@ +//! Completion tests for predicates and bounds. +use expect_test::{expect, Expect}; + +use crate::tests::{completion_list, BASE_FIXTURE}; + +fn check(ra_fixture: &str, expect: Expect) { + let actual = completion_list(&format!("{}\n{}", BASE_FIXTURE, ra_fixture)); + expect.assert_eq(&actual) +} + +#[test] +fn predicate_start() { + // FIXME: `for` kw + check( + r#" +struct Foo<'lt, T, const C: usize> where $0 {} +"#, + expect![[r#" + tt Trait + en Enum + st Record + st Tuple + md module + st Foo<…> + st Unit + ma makro!(…) macro_rules! makro + bt u32 + "#]], + ); +} + +#[test] +fn bound_for_type_pred() { + // FIXME: only show traits, macros and modules + check( + r#" +struct Foo<'lt, T, const C: usize> where T: $0 {} +"#, + expect![[r#" + sp Self + tp T + tt Trait + en Enum + st Record + st Tuple + md module + st Foo<…> + st Unit + ma makro!(…) macro_rules! makro + bt u32 + "#]], + ); +} + +#[test] +fn bound_for_lifetime_pred() { + // FIXME: should only show lifetimes here + check( + r#" +struct Foo<'lt, T, const C: usize> where 'lt: $0 {} +"#, + expect![[r#" + sp Self + tp T + tt Trait + en Enum + st Record + st Tuple + md module + st Foo<…> + st Unit + ma makro!(…) macro_rules! makro + bt u32 + "#]], + ); +} + +#[test] +fn bound_for_for_pred() { + // FIXME: only show traits, macros and modules + check( + r#" +struct Foo<'lt, T, const C: usize> where for<'a> T: $0 {} +"#, + expect![[r#" + sp Self + tp T + tt Trait + en Enum + st Record + st Tuple + md module + st Foo<…> + st Unit + ma makro!(…) macro_rules! makro + bt u32 + "#]], + ); +} + +#[test] +fn param_list_for_for_pred() { + check( + r#" +struct Foo<'lt, T, const C: usize> where for<'a> $0 {} +"#, + expect![[r#" + tt Trait + en Enum + st Record + st Tuple + md module + st Foo<…> + st Unit + ma makro!(…) macro_rules! makro + bt u32 + "#]], + ); +} + +#[test] +fn pred_on_fn_in_impl() { + // FIXME: only show traits, macros and modules + check( + r#" +impl Record { + fn method(self) where $0 {} +} +"#, + expect![[r#" + sp Self + tt Trait + en Enum + st Record + st Tuple + md module + st Unit + ma makro!(…) macro_rules! makro + bt u32 + "#]], + ); +} diff --git a/crates/ide_completion/src/tests/where_clause.rs b/crates/ide_completion/src/tests/where_clause.rs deleted file mode 100644 index 0395cbf37a7..00000000000 --- a/crates/ide_completion/src/tests/where_clause.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Completion tests for inside of where clauses. -//! -//! The parent of the where clause tends to bleed completions of itself into the where clause so this -//! has to be thoroughly tested. -use expect_test::{expect, Expect}; - -use crate::tests::completion_list; - -fn check(ra_fixture: &str, expect: Expect) { - let actual = completion_list(ra_fixture); - expect.assert_eq(&actual) -} From 9abd28ac372f8b883ab3fef966543779b97dc9b4 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 23 Jun 2021 19:10:03 +0200 Subject: [PATCH 3/4] Restrict type bound completions to traits, modules and macros --- .../src/completions/unqualified_path.rs | 14 ++++++++++ crates/ide_completion/src/patterns.rs | 10 +++++++ crates/ide_completion/src/tests/predicate.rs | 26 ------------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index 380c1e07977..5abd6ee37f7 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs @@ -36,6 +36,20 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC return; } + if matches!(&ctx.completion_location, Some(ImmediateLocation::TypeBound)) { + ctx.scope.process_all_names(&mut |name, res| { + let add_resolution = match res { + ScopeDef::MacroDef(mac) => mac.is_fn_like(), + ScopeDef::ModuleDef(hir::ModuleDef::Trait(_) | hir::ModuleDef::Module(_)) => true, + _ => false, + }; + if add_resolution { + acc.add_resolution(ctx, name, &res); + } + }); + return; + } + if !ctx.expects_type() { if let Some(hir::Adt::Enum(e)) = ctx.expected_type.as_ref().and_then(|ty| ty.strip_references().as_adt()) diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs index 757c9a3daa3..b673ce8c9ad 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs @@ -36,6 +36,7 @@ pub(crate) enum ImmediateLocation { IdentPat, BlockExpr, ItemList, + TypeBound, // Fake file ast node Attribute(ast::Attr), // Fake file ast node @@ -154,6 +155,13 @@ pub(crate) fn determine_location( ast::NameLike::Lifetime(lt) => lt.syntax().clone(), }; + match_ast! { + match node { + ast::TypeBoundList(_it) => return Some(ImmediateLocation::TypeBound), + _ => (), + } + }; + let parent = match node.parent() { Some(parent) => match ast::MacroCall::cast(parent.clone()) { // When a path is being typed in an (Assoc)ItemList the parser will always emit a macro_call. @@ -195,6 +203,8 @@ pub(crate) fn determine_location( }, ast::TupleField(_it) => ImmediateLocation::TupleField, ast::TupleFieldList(_it) => ImmediateLocation::TupleField, + ast::TypeBound(_it) => ImmediateLocation::TypeBound, + ast::TypeBoundList(_it) => ImmediateLocation::TypeBound, ast::AssocItemList(it) => match it.syntax().parent().map(|it| it.kind()) { Some(IMPL) => ImmediateLocation::Impl, Some(TRAIT) => ImmediateLocation::Trait, diff --git a/crates/ide_completion/src/tests/predicate.rs b/crates/ide_completion/src/tests/predicate.rs index 04ff08669df..2130c538f2f 100644 --- a/crates/ide_completion/src/tests/predicate.rs +++ b/crates/ide_completion/src/tests/predicate.rs @@ -37,17 +37,9 @@ fn bound_for_type_pred() { struct Foo<'lt, T, const C: usize> where T: $0 {} "#, expect![[r#" - sp Self - tp T tt Trait - en Enum - st Record - st Tuple md module - st Foo<…> - st Unit ma makro!(…) macro_rules! makro - bt u32 "#]], ); } @@ -60,40 +52,23 @@ fn bound_for_lifetime_pred() { struct Foo<'lt, T, const C: usize> where 'lt: $0 {} "#, expect![[r#" - sp Self - tp T tt Trait - en Enum - st Record - st Tuple md module - st Foo<…> - st Unit ma makro!(…) macro_rules! makro - bt u32 "#]], ); } #[test] fn bound_for_for_pred() { - // FIXME: only show traits, macros and modules check( r#" struct Foo<'lt, T, const C: usize> where for<'a> T: $0 {} "#, expect![[r#" - sp Self - tp T tt Trait - en Enum - st Record - st Tuple md module - st Foo<…> - st Unit ma makro!(…) macro_rules! makro - bt u32 "#]], ); } @@ -120,7 +95,6 @@ struct Foo<'lt, T, const C: usize> where for<'a> $0 {} #[test] fn pred_on_fn_in_impl() { - // FIXME: only show traits, macros and modules check( r#" impl Record { From 85736f2dc9f42188e316f3aca8c391c48f5c32b1 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 23 Jun 2021 19:13:24 +0200 Subject: [PATCH 4/4] Fix incorrect base fixture in ide_completion tests --- crates/ide_completion/src/tests.rs | 5 ++- crates/ide_completion/src/tests/item_list.rs | 32 ++++++++------- crates/ide_completion/src/tests/items.rs | 14 ++++--- crates/ide_completion/src/tests/pattern.rs | 23 ++++++----- crates/ide_completion/src/tests/predicate.rs | 42 +++++++++++--------- 5 files changed, 67 insertions(+), 49 deletions(-) diff --git a/crates/ide_completion/src/tests.rs b/crates/ide_completion/src/tests.rs index 89faa9526c4..d2a502b9f9f 100644 --- a/crates/ide_completion/src/tests.rs +++ b/crates/ide_completion/src/tests.rs @@ -40,8 +40,11 @@ static STATIC: Unit = Unit; const CONST: Unit = Unit; struct Record { field: u32 } struct Tuple(u32); -struct Unit +struct Unit; +#[macro_export] macro_rules! makro {} +#[rustc_builtin_macro] +pub macro Clone {} "#; pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig { diff --git a/crates/ide_completion/src/tests/item_list.rs b/crates/ide_completion/src/tests/item_list.rs index ae71adf8e00..77f00e8e5c1 100644 --- a/crates/ide_completion/src/tests/item_list.rs +++ b/crates/ide_completion/src/tests/item_list.rs @@ -11,7 +11,7 @@ fn check(ra_fixture: &str, expect: Expect) { fn in_mod_item_list() { check( r#"mod tests { $0 }"#, - expect![[r#" + expect![[r##" kw pub(crate) kw pub kw unsafe @@ -30,8 +30,8 @@ fn in_mod_item_list() { sn tmod (Test module) sn tfn (Test function) sn macro_rules - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ) } @@ -39,7 +39,7 @@ fn in_mod_item_list() { fn in_source_file_item_list() { check( r#"$0"#, - expect![[r#" + expect![[r##" kw pub(crate) kw pub kw unsafe @@ -58,9 +58,10 @@ fn in_source_file_item_list() { sn tmod (Test module) sn tfn (Test function) sn macro_rules + ma makro!(…) #[macro_export] macro_rules! makro md module - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ) } @@ -95,7 +96,7 @@ fn in_item_list_after_attr() { fn in_qualified_path() { check( r#"crate::$0"#, - expect![[r#" + expect![[r##" kw pub(crate) kw pub kw unsafe @@ -111,8 +112,9 @@ fn in_qualified_path() { kw enum kw struct kw union + ma makro!(…) #[macro_export] macro_rules! makro md module - "#]], + "##]], ) } @@ -165,16 +167,17 @@ fn after_visibility_unsafe() { fn in_impl_assoc_item_list() { check( r#"impl Struct { $0 }"#, - expect![[r#" + expect![[r##" kw pub(crate) kw pub kw unsafe kw fn kw const kw type + ma makro!(…) #[macro_export] macro_rules! makro md module - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ) } @@ -197,13 +200,14 @@ fn in_impl_assoc_item_list_after_attr() { fn in_trait_assoc_item_list() { check( r"trait Foo { $0 }", - expect![[r#" + expect![[r##" kw unsafe kw fn kw const kw type md module - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ); } diff --git a/crates/ide_completion/src/tests/items.rs b/crates/ide_completion/src/tests/items.rs index 5acfdcc85da..ef2015107e3 100644 --- a/crates/ide_completion/src/tests/items.rs +++ b/crates/ide_completion/src/tests/items.rs @@ -17,16 +17,17 @@ fn target_type_or_trait_in_impl_block() { r#" impl Tra$0 "#, - expect![[r#" + expect![[r##" tt Trait en Enum st Record st Tuple + ma makro!(…) #[macro_export] macro_rules! makro md module st Unit - ma makro!(…) macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro bt u32 - "#]], + "##]], ) } @@ -36,16 +37,17 @@ fn target_type_in_trait_impl_block() { r#" impl Trait for Str$0 "#, - expect![[r#" + expect![[r##" tt Trait en Enum st Record st Tuple + ma makro!(…) #[macro_export] macro_rules! makro md module st Unit - ma makro!(…) macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro bt u32 - "#]], + "##]], ) } diff --git a/crates/ide_completion/src/tests/pattern.rs b/crates/ide_completion/src/tests/pattern.rs index 48c2fa9aa28..9d70aca3c95 100644 --- a/crates/ide_completion/src/tests/pattern.rs +++ b/crates/ide_completion/src/tests/pattern.rs @@ -109,7 +109,7 @@ fn foo() { if let a$0 } "#, - expect![[r#" + expect![[r##" kw mut en Enum bn Record Record { field$1 }$0 @@ -117,12 +117,13 @@ fn foo() { bn Tuple Tuple($1)$0 st Tuple md module + st Unit + ma makro!(…) #[macro_export] macro_rules! makro bn TupleV TupleV($1)$0 ev TupleV - st Unit ct CONST - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ); } @@ -134,15 +135,16 @@ fn foo() { let a$0 } "#, - expect![[r#" + expect![[r##" kw mut bn Record Record { field$1 }$0 st Record bn Tuple Tuple($1)$0 st Tuple st Unit - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ); } @@ -153,15 +155,16 @@ fn in_param() { fn foo(a$0) { } "#, - expect![[r#" + expect![[r##" kw mut bn Record Record { field$1 }: Record$0 st Record bn Tuple Tuple($1): Tuple$0 st Tuple st Unit - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ); } diff --git a/crates/ide_completion/src/tests/predicate.rs b/crates/ide_completion/src/tests/predicate.rs index 2130c538f2f..2b8ba86b238 100644 --- a/crates/ide_completion/src/tests/predicate.rs +++ b/crates/ide_completion/src/tests/predicate.rs @@ -15,7 +15,7 @@ fn predicate_start() { r#" struct Foo<'lt, T, const C: usize> where $0 {} "#, - expect![[r#" + expect![[r##" tt Trait en Enum st Record @@ -23,9 +23,10 @@ struct Foo<'lt, T, const C: usize> where $0 {} md module st Foo<…> st Unit - ma makro!(…) macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro bt u32 - "#]], + "##]], ); } @@ -36,11 +37,12 @@ fn bound_for_type_pred() { r#" struct Foo<'lt, T, const C: usize> where T: $0 {} "#, - expect![[r#" + expect![[r##" tt Trait md module - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ); } @@ -51,11 +53,12 @@ fn bound_for_lifetime_pred() { r#" struct Foo<'lt, T, const C: usize> where 'lt: $0 {} "#, - expect![[r#" + expect![[r##" tt Trait md module - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ); } @@ -65,11 +68,12 @@ fn bound_for_for_pred() { r#" struct Foo<'lt, T, const C: usize> where for<'a> T: $0 {} "#, - expect![[r#" + expect![[r##" tt Trait md module - ma makro!(…) macro_rules! makro - "#]], + ma makro!(…) #[macro_export] macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro + "##]], ); } @@ -79,7 +83,7 @@ fn param_list_for_for_pred() { r#" struct Foo<'lt, T, const C: usize> where for<'a> $0 {} "#, - expect![[r#" + expect![[r##" tt Trait en Enum st Record @@ -87,9 +91,10 @@ struct Foo<'lt, T, const C: usize> where for<'a> $0 {} md module st Foo<…> st Unit - ma makro!(…) macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro bt u32 - "#]], + "##]], ); } @@ -101,16 +106,17 @@ impl Record { fn method(self) where $0 {} } "#, - expect![[r#" + expect![[r##" sp Self tt Trait en Enum st Record st Tuple + ma makro!(…) #[macro_export] macro_rules! makro md module st Unit - ma makro!(…) macro_rules! makro + ma makro!(…) #[macro_export] macro_rules! makro bt u32 - "#]], + "##]], ); }