diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-17 18:50:15 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-17 18:50:15 +0100 |
commit | 53d26164c6608fd5149180c91fa49c7cde79706f (patch) | |
tree | e65e8eeb44c21a0f1e378c0c32a565c3c09375bc /crates/ide_completion/src/completions/record.rs | |
parent | ce926aebc4461e38535047958c0b6f72b7a0c0ea (diff) | |
parent | 08c220ab2c4651f38d3029898706f2a996bf2c6b (diff) |
Merge #9316
9316: internal: add default to minicore r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide_completion/src/completions/record.rs')
-rw-r--r-- | crates/ide_completion/src/completions/record.rs | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/crates/ide_completion/src/completions/record.rs b/crates/ide_completion/src/completions/record.rs index 47523f72f..e876337f1 100644 --- a/crates/ide_completion/src/completions/record.rs +++ b/crates/ide_completion/src/completions/record.rs | |||
@@ -48,10 +48,9 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> | |||
48 | #[cfg(test)] | 48 | #[cfg(test)] |
49 | mod tests { | 49 | mod tests { |
50 | use expect_test::{expect, Expect}; | 50 | use expect_test::{expect, Expect}; |
51 | use ide_db::helpers::FamousDefs; | ||
52 | 51 | ||
53 | use crate::{ | 52 | use crate::{ |
54 | tests::{self, filtered_completion_list}, | 53 | tests::{check_edit, filtered_completion_list}, |
55 | CompletionKind, | 54 | CompletionKind, |
56 | }; | 55 | }; |
57 | 56 | ||
@@ -61,31 +60,17 @@ mod tests { | |||
61 | } | 60 | } |
62 | 61 | ||
63 | fn check_snippet(ra_fixture: &str, expect: Expect) { | 62 | fn check_snippet(ra_fixture: &str, expect: Expect) { |
64 | let actual = filtered_completion_list( | 63 | let actual = filtered_completion_list(ra_fixture, CompletionKind::Snippet); |
65 | &format!("//- /main.rs crate:main deps:core\n{}\n{}", ra_fixture, FamousDefs::FIXTURE), | ||
66 | CompletionKind::Snippet, | ||
67 | ); | ||
68 | expect.assert_eq(&actual); | 64 | expect.assert_eq(&actual); |
69 | } | 65 | } |
70 | 66 | ||
71 | fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | ||
72 | tests::check_edit( | ||
73 | what, | ||
74 | &format!( | ||
75 | "//- /main.rs crate:main deps:core{}\n{}", | ||
76 | ra_fixture_before, | ||
77 | FamousDefs::FIXTURE, | ||
78 | ), | ||
79 | &(ra_fixture_after.to_owned() + "\n"), | ||
80 | ); | ||
81 | } | ||
82 | |||
83 | #[test] | 67 | #[test] |
84 | fn test_record_literal_field_default() { | 68 | fn test_record_literal_field_default() { |
85 | let test_code = r#" | 69 | let test_code = r#" |
70 | //- minicore: default | ||
86 | struct S { foo: u32, bar: usize } | 71 | struct S { foo: u32, bar: usize } |
87 | 72 | ||
88 | impl core::default::Default for S { | 73 | impl Default for S { |
89 | fn default() -> Self { | 74 | fn default() -> Self { |
90 | S { | 75 | S { |
91 | foo: 0, | 76 | foo: 0, |
@@ -121,9 +106,10 @@ fn process(f: S) { | |||
121 | check_edit( | 106 | check_edit( |
122 | "..Default::default()", | 107 | "..Default::default()", |
123 | r#" | 108 | r#" |
109 | //- minicore: default | ||
124 | struct S { foo: u32, bar: usize } | 110 | struct S { foo: u32, bar: usize } |
125 | 111 | ||
126 | impl core::default::Default for S { | 112 | impl Default for S { |
127 | fn default() -> Self { | 113 | fn default() -> Self { |
128 | S { | 114 | S { |
129 | foo: 0, | 115 | foo: 0, |
@@ -142,7 +128,7 @@ fn process(f: S) { | |||
142 | r#" | 128 | r#" |
143 | struct S { foo: u32, bar: usize } | 129 | struct S { foo: u32, bar: usize } |
144 | 130 | ||
145 | impl core::default::Default for S { | 131 | impl Default for S { |
146 | fn default() -> Self { | 132 | fn default() -> Self { |
147 | S { | 133 | S { |
148 | foo: 0, | 134 | foo: 0, |