aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src')
-rw-r--r--crates/ide_completion/src/completions/attribute.rs6
-rw-r--r--crates/ide_completion/src/completions/attribute/derive.rs7
-rw-r--r--crates/ide_completion/src/completions/attribute/lint.rs1
-rw-r--r--crates/ide_completion/src/completions/keyword.rs59
-rw-r--r--crates/ide_completion/src/completions/lifetime.rs14
-rw-r--r--crates/ide_completion/src/completions/mod_.rs138
-rw-r--r--crates/ide_completion/src/completions/qualified_path.rs20
-rw-r--r--crates/ide_completion/src/completions/snippet.rs6
-rw-r--r--crates/ide_completion/src/completions/unqualified_path.rs22
-rw-r--r--crates/ide_completion/src/context.rs4
-rw-r--r--crates/ide_completion/src/tests.rs9
-rw-r--r--crates/ide_completion/src/tests/items.rs127
12 files changed, 242 insertions, 171 deletions
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs
index 3866c5917..f3b11e72d 100644
--- a/crates/ide_completion/src/completions/attribute.rs
+++ b/crates/ide_completion/src/completions/attribute.rs
@@ -322,7 +322,7 @@ mod tests {
322 322
323 use expect_test::{expect, Expect}; 323 use expect_test::{expect, Expect};
324 324
325 use crate::{tests::filtered_completion_list, CompletionKind}; 325 use crate::tests::completion_list;
326 326
327 #[test] 327 #[test]
328 fn attributes_are_sorted() { 328 fn attributes_are_sorted() {
@@ -341,7 +341,7 @@ mod tests {
341 } 341 }
342 342
343 fn check(ra_fixture: &str, expect: Expect) { 343 fn check(ra_fixture: &str, expect: Expect) {
344 let actual = filtered_completion_list(ra_fixture, CompletionKind::Attribute); 344 let actual = completion_list(ra_fixture);
345 expect.assert_eq(&actual); 345 expect.assert_eq(&actual);
346 } 346 }
347 347
@@ -786,6 +786,7 @@ mod tests {
786 at target_feature = "…" 786 at target_feature = "…"
787 at test 787 at test
788 at track_caller 788 at track_caller
789 kw return
789 "#]], 790 "#]],
790 ); 791 );
791 } 792 }
@@ -801,6 +802,7 @@ mod tests {
801 at deny(…) 802 at deny(…)
802 at forbid(…) 803 at forbid(…)
803 at warn(…) 804 at warn(…)
805 kw return
804 "#]], 806 "#]],
805 ); 807 );
806 } 808 }
diff --git a/crates/ide_completion/src/completions/attribute/derive.rs b/crates/ide_completion/src/completions/attribute/derive.rs
index 5201095e8..6fe41e0d6 100644
--- a/crates/ide_completion/src/completions/attribute/derive.rs
+++ b/crates/ide_completion/src/completions/attribute/derive.rs
@@ -82,7 +82,7 @@ const DEFAULT_DERIVE_COMPLETIONS: &[DeriveDependencies] = &[
82mod tests { 82mod tests {
83 use expect_test::{expect, Expect}; 83 use expect_test::{expect, Expect};
84 84
85 use crate::{tests::filtered_completion_list, CompletionKind}; 85 use crate::tests::completion_list;
86 86
87 fn check(ra_fixture: &str, expect: Expect) { 87 fn check(ra_fixture: &str, expect: Expect) {
88 let builtin_derives = r#" 88 let builtin_derives = r#"
@@ -106,10 +106,7 @@ pub macro PartialOrd {}
106pub macro Ord {} 106pub macro Ord {}
107 107
108"#; 108"#;
109 let actual = filtered_completion_list( 109 let actual = completion_list(&format!("{} {}", builtin_derives, ra_fixture));
110 &format!("{} {}", builtin_derives, ra_fixture),
111 CompletionKind::Attribute,
112 );
113 expect.assert_eq(&actual); 110 expect.assert_eq(&actual);
114 } 111 }
115 112
diff --git a/crates/ide_completion/src/completions/attribute/lint.rs b/crates/ide_completion/src/completions/attribute/lint.rs
index 4812b075c..1ddc38986 100644
--- a/crates/ide_completion/src/completions/attribute/lint.rs
+++ b/crates/ide_completion/src/completions/attribute/lint.rs
@@ -33,7 +33,6 @@ pub(super) fn complete_lint(
33 33
34#[cfg(test)] 34#[cfg(test)]
35mod tests { 35mod tests {
36
37 use crate::tests::check_edit; 36 use crate::tests::check_edit;
38 37
39 #[test] 38 #[test]
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs
index 9754122a0..c99fdef05 100644
--- a/crates/ide_completion/src/completions/keyword.rs
+++ b/crates/ide_completion/src/completions/keyword.rs
@@ -37,17 +37,6 @@ pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
37 } 37 }
38 }; 38 };
39 } 39 }
40
41 // Suggest .await syntax for types that implement Future trait
42 if let Some(receiver) = ctx.dot_receiver() {
43 if let Some(ty) = ctx.sema.type_of_expr(receiver) {
44 if ty.impls_future(ctx.db) {
45 let mut item = kw_completion("await");
46 item.detail("expr.await");
47 item.add_to(acc);
48 }
49 };
50 }
51} 40}
52 41
53pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { 42pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) {
@@ -59,6 +48,19 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
59 cov_mark::hit!(no_keyword_completion_in_record_lit); 48 cov_mark::hit!(no_keyword_completion_in_record_lit);
60 return; 49 return;
61 } 50 }
51
52 // Suggest .await syntax for types that implement Future trait
53 if let Some(receiver) = ctx.dot_receiver() {
54 if let Some(ty) = ctx.sema.type_of_expr(receiver) {
55 if ty.impls_future(ctx.db) {
56 let mut item =
57 CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), "await");
58 item.kind(CompletionItemKind::Keyword).detail("expr.await");
59 item.add_to(acc);
60 }
61 };
62 }
63
62 let mut add_keyword = |kw, snippet| add_keyword(ctx, acc, kw, snippet); 64 let mut add_keyword = |kw, snippet| add_keyword(ctx, acc, kw, snippet);
63 65
64 let expects_assoc_item = ctx.expects_assoc_item(); 66 let expects_assoc_item = ctx.expects_assoc_item();
@@ -67,6 +69,9 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
67 69
68 if ctx.has_impl_or_trait_prev_sibling() { 70 if ctx.has_impl_or_trait_prev_sibling() {
69 add_keyword("where", "where "); 71 add_keyword("where", "where ");
72 if ctx.has_impl_prev_sibling() {
73 add_keyword("for", "for ");
74 }
70 return; 75 return;
71 } 76 }
72 if ctx.previous_token_is(T![unsafe]) { 77 if ctx.previous_token_is(T![unsafe]) {
@@ -386,22 +391,6 @@ fn quux() -> i32 {
386 } 391 }
387 392
388 #[test] 393 #[test]
389 fn test_where_keyword() {
390 check(
391 r"trait A $0",
392 expect![[r#"
393 kw where
394 "#]],
395 );
396 check(
397 r"impl A $0",
398 expect![[r#"
399 kw where
400 "#]],
401 );
402 }
403
404 #[test]
405 fn no_keyword_completion_in_comments() { 394 fn no_keyword_completion_in_comments() {
406 cov_mark::check!(no_keyword_completion_in_comments); 395 cov_mark::check!(no_keyword_completion_in_comments);
407 check( 396 check(
@@ -478,22 +467,6 @@ fn foo() {
478 } 467 }
479 468
480 #[test] 469 #[test]
481 fn before_field() {
482 check(
483 r#"
484struct Foo {
485 $0
486 pub f: i32,
487}
488"#,
489 expect![[r#"
490 kw pub(crate)
491 kw pub
492 "#]],
493 )
494 }
495
496 #[test]
497 fn skip_struct_initializer() { 470 fn skip_struct_initializer() {
498 cov_mark::check!(no_keyword_completion_in_record_lit); 471 cov_mark::check!(no_keyword_completion_in_record_lit);
499 check( 472 check(
diff --git a/crates/ide_completion/src/completions/lifetime.rs b/crates/ide_completion/src/completions/lifetime.rs
index 36f595164..abf6935c9 100644
--- a/crates/ide_completion/src/completions/lifetime.rs
+++ b/crates/ide_completion/src/completions/lifetime.rs
@@ -49,19 +49,11 @@ pub(crate) fn complete_label(acc: &mut Completions, ctx: &CompletionContext) {
49mod tests { 49mod tests {
50 use expect_test::{expect, Expect}; 50 use expect_test::{expect, Expect};
51 51
52 use crate::{ 52 use crate::tests::{check_edit, completion_list};
53 tests::{check_edit, filtered_completion_list_with_config, TEST_CONFIG},
54 CompletionConfig, CompletionKind,
55 };
56 53
57 fn check(ra_fixture: &str, expect: Expect) { 54 fn check(ra_fixture: &str, expect: Expect) {
58 check_with_config(TEST_CONFIG, ra_fixture, expect); 55 let actual = completion_list(ra_fixture);
59 } 56 expect.assert_eq(&actual);
60
61 fn check_with_config(config: CompletionConfig, ra_fixture: &str, expect: Expect) {
62 let actual =
63 filtered_completion_list_with_config(config, ra_fixture, CompletionKind::Reference);
64 expect.assert_eq(&actual)
65 } 57 }
66 58
67 #[test] 59 #[test]
diff --git a/crates/ide_completion/src/completions/mod_.rs b/crates/ide_completion/src/completions/mod_.rs
index 5def0d06a..1c864c0e7 100644
--- a/crates/ide_completion/src/completions/mod_.rs
+++ b/crates/ide_completion/src/completions/mod_.rs
@@ -141,11 +141,11 @@ fn module_chain_to_containing_module_file(
141 141
142#[cfg(test)] 142#[cfg(test)]
143mod tests { 143mod tests {
144 use crate::{tests::filtered_completion_list, CompletionKind}; 144 use crate::tests::completion_list;
145 use expect_test::{expect, Expect}; 145 use expect_test::{expect, Expect};
146 146
147 fn check(ra_fixture: &str, expect: Expect) { 147 fn check(ra_fixture: &str, expect: Expect) {
148 let actual = filtered_completion_list(ra_fixture, CompletionKind::Magic); 148 let actual = completion_list(ra_fixture);
149 expect.assert_eq(&actual); 149 expect.assert_eq(&actual);
150 } 150 }
151 151
@@ -153,17 +153,17 @@ mod tests {
153 fn lib_module_completion() { 153 fn lib_module_completion() {
154 check( 154 check(
155 r#" 155 r#"
156 //- /lib.rs 156//- /lib.rs
157 mod $0 157mod $0
158 //- /foo.rs 158//- /foo.rs
159 fn foo() {} 159fn foo() {}
160 //- /foo/ignored_foo.rs 160//- /foo/ignored_foo.rs
161 fn ignored_foo() {} 161fn ignored_foo() {}
162 //- /bar/mod.rs 162//- /bar/mod.rs
163 fn bar() {} 163fn bar() {}
164 //- /bar/ignored_bar.rs 164//- /bar/ignored_bar.rs
165 fn ignored_bar() {} 165fn ignored_bar() {}
166 "#, 166"#,
167 expect![[r#" 167 expect![[r#"
168 md foo; 168 md foo;
169 md bar; 169 md bar;
@@ -175,13 +175,13 @@ mod tests {
175 fn no_module_completion_with_module_body() { 175 fn no_module_completion_with_module_body() {
176 check( 176 check(
177 r#" 177 r#"
178 //- /lib.rs 178//- /lib.rs
179 mod $0 { 179mod $0 {
180 180
181 } 181}
182 //- /foo.rs 182//- /foo.rs
183 fn foo() {} 183fn foo() {}
184 "#, 184"#,
185 expect![[r#""#]], 185 expect![[r#""#]],
186 ); 186 );
187 } 187 }
@@ -190,17 +190,17 @@ mod tests {
190 fn main_module_completion() { 190 fn main_module_completion() {
191 check( 191 check(
192 r#" 192 r#"
193 //- /main.rs 193//- /main.rs
194 mod $0 194mod $0
195 //- /foo.rs 195//- /foo.rs
196 fn foo() {} 196fn foo() {}
197 //- /foo/ignored_foo.rs 197//- /foo/ignored_foo.rs
198 fn ignored_foo() {} 198fn ignored_foo() {}
199 //- /bar/mod.rs 199//- /bar/mod.rs
200 fn bar() {} 200fn bar() {}
201 //- /bar/ignored_bar.rs 201//- /bar/ignored_bar.rs
202 fn ignored_bar() {} 202fn ignored_bar() {}
203 "#, 203"#,
204 expect![[r#" 204 expect![[r#"
205 md foo; 205 md foo;
206 md bar; 206 md bar;
@@ -212,13 +212,13 @@ mod tests {
212 fn main_test_module_completion() { 212 fn main_test_module_completion() {
213 check( 213 check(
214 r#" 214 r#"
215 //- /main.rs 215//- /main.rs
216 mod tests { 216mod tests {
217 mod $0; 217 mod $0;
218 } 218}
219 //- /tests/foo.rs 219//- /tests/foo.rs
220 fn foo() {} 220fn foo() {}
221 "#, 221"#,
222 expect![[r#" 222 expect![[r#"
223 md foo 223 md foo
224 "#]], 224 "#]],
@@ -229,19 +229,19 @@ mod tests {
229 fn directly_nested_module_completion() { 229 fn directly_nested_module_completion() {
230 check( 230 check(
231 r#" 231 r#"
232 //- /lib.rs 232//- /lib.rs
233 mod foo; 233mod foo;
234 //- /foo.rs 234//- /foo.rs
235 mod $0; 235mod $0;
236 //- /foo/bar.rs 236//- /foo/bar.rs
237 fn bar() {} 237fn bar() {}
238 //- /foo/bar/ignored_bar.rs 238//- /foo/bar/ignored_bar.rs
239 fn ignored_bar() {} 239fn ignored_bar() {}
240 //- /foo/baz/mod.rs 240//- /foo/baz/mod.rs
241 fn baz() {} 241fn baz() {}
242 //- /foo/moar/ignored_moar.rs 242//- /foo/moar/ignored_moar.rs
243 fn ignored_moar() {} 243fn ignored_moar() {}
244 "#, 244"#,
245 expect![[r#" 245 expect![[r#"
246 md bar 246 md bar
247 md baz 247 md baz
@@ -253,15 +253,15 @@ mod tests {
253 fn nested_in_source_module_completion() { 253 fn nested_in_source_module_completion() {
254 check( 254 check(
255 r#" 255 r#"
256 //- /lib.rs 256//- /lib.rs
257 mod foo; 257mod foo;
258 //- /foo.rs 258//- /foo.rs
259 mod bar { 259mod bar {
260 mod $0 260 mod $0
261 } 261}
262 //- /foo/bar/baz.rs 262//- /foo/bar/baz.rs
263 fn baz() {} 263fn baz() {}
264 "#, 264"#,
265 expect![[r#" 265 expect![[r#"
266 md baz; 266 md baz;
267 "#]], 267 "#]],
@@ -299,16 +299,16 @@ mod tests {
299 fn already_declared_bin_module_completion_omitted() { 299 fn already_declared_bin_module_completion_omitted() {
300 check( 300 check(
301 r#" 301 r#"
302 //- /src/bin.rs crate:main 302//- /src/bin.rs crate:main
303 fn main() {} 303fn main() {}
304 //- /src/bin/foo.rs 304//- /src/bin/foo.rs
305 mod $0 305mod $0
306 //- /src/bin/bar.rs 306//- /src/bin/bar.rs
307 mod foo; 307mod foo;
308 fn bar() {} 308fn bar() {}
309 //- /src/bin/bar/bar_ignored.rs 309//- /src/bin/bar/bar_ignored.rs
310 fn bar_ignored() {} 310fn bar_ignored() {}
311 "#, 311"#,
312 expect![[r#""#]], 312 expect![[r#""#]],
313 ); 313 );
314 } 314 }
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs
index da3385bdc..f5dbd203b 100644
--- a/crates/ide_completion/src/completions/qualified_path.rs
+++ b/crates/ide_completion/src/completions/qualified_path.rs
@@ -562,26 +562,6 @@ fn f() {m::$0}
562 } 562 }
563 563
564 #[test] 564 #[test]
565 fn completes_in_assoc_item_list() {
566 check(
567 r#"
568#[macro_export]
569macro_rules! foo { () => {} }
570mod bar {}
571
572struct MyStruct {}
573impl MyStruct {
574 crate::$0
575}
576"#,
577 expect![[r##"
578 md bar
579 ma foo!(…) #[macro_export] macro_rules! foo
580 "##]],
581 );
582 }
583
584 #[test]
585 fn completes_reexported_items_under_correct_name() { 565 fn completes_reexported_items_under_correct_name() {
586 check( 566 check(
587 r#" 567 r#"
diff --git a/crates/ide_completion/src/completions/snippet.rs b/crates/ide_completion/src/completions/snippet.rs
index 81ddfa34f..cbc20cc2c 100644
--- a/crates/ide_completion/src/completions/snippet.rs
+++ b/crates/ide_completion/src/completions/snippet.rs
@@ -36,7 +36,11 @@ pub(crate) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte
36} 36}
37 37
38pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) { 38pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) {
39 if !ctx.expects_item() || ctx.previous_token_is(T![unsafe]) || ctx.path_qual().is_some() { 39 if !ctx.expects_item()
40 || ctx.previous_token_is(T![unsafe])
41 || ctx.path_qual().is_some()
42 || ctx.has_impl_or_trait_prev_sibling()
43 {
40 return; 44 return;
41 } 45 }
42 if ctx.has_visibility_prev_sibling() { 46 if ctx.has_visibility_prev_sibling() {
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs
index 77c6d706f..81c4fb305 100644
--- a/crates/ide_completion/src/completions/unqualified_path.rs
+++ b/crates/ide_completion/src/completions/unqualified_path.rs
@@ -6,7 +6,7 @@ use syntax::{ast, AstNode};
6use crate::{patterns::ImmediateLocation, CompletionContext, Completions}; 6use crate::{patterns::ImmediateLocation, CompletionContext, Completions};
7 7
8pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) { 8pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) {
9 if ctx.is_path_disallowed() || !ctx.is_trivial_path() { 9 if ctx.is_path_disallowed() || !ctx.is_trivial_path() || ctx.has_impl_or_trait_prev_sibling() {
10 return; 10 return;
11 } 11 }
12 12
@@ -68,6 +68,9 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
68 return; 68 return;
69 } 69 }
70 let add_resolution = match res { 70 let add_resolution = match res {
71 ScopeDef::ImplSelfType(_) => {
72 !ctx.previous_token_is(syntax::T![impl]) && !ctx.previous_token_is(syntax::T![for])
73 }
71 // Don't suggest attribute macros and derives. 74 // Don't suggest attribute macros and derives.
72 ScopeDef::MacroDef(mac) => mac.is_fn_like(), 75 ScopeDef::MacroDef(mac) => mac.is_fn_like(),
73 // no values in type places 76 // no values in type places
@@ -715,23 +718,6 @@ fn f() {}
715 } 718 }
716 719
717 #[test] 720 #[test]
718 fn completes_target_type_or_trait_in_impl_block() {
719 check(
720 r#"
721trait MyTrait {}
722struct MyStruct {}
723
724impl My$0
725"#,
726 expect![[r#"
727 sp Self
728 tt MyTrait
729 st MyStruct
730 "#]],
731 )
732 }
733
734 #[test]
735 fn completes_types_and_const_in_arg_list() { 721 fn completes_types_and_const_in_arg_list() {
736 check( 722 check(
737 r#" 723 r#"
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index 84b2bcf9f..98fb36042 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -304,6 +304,10 @@ impl<'a> CompletionContext<'a> {
304 ) 304 )
305 } 305 }
306 306
307 pub(crate) fn has_impl_prev_sibling(&self) -> bool {
308 matches!(self.prev_sibling, Some(ImmediatePrevSibling::ImplDefType))
309 }
310
307 pub(crate) fn has_visibility_prev_sibling(&self) -> bool { 311 pub(crate) fn has_visibility_prev_sibling(&self) -> bool {
308 matches!(self.prev_sibling, Some(ImmediatePrevSibling::Visibility)) 312 matches!(self.prev_sibling, Some(ImmediatePrevSibling::Visibility))
309 } 313 }
diff --git a/crates/ide_completion/src/tests.rs b/crates/ide_completion/src/tests.rs
index 89c7fb524..1ea6017ce 100644
--- a/crates/ide_completion/src/tests.rs
+++ b/crates/ide_completion/src/tests.rs
@@ -1,5 +1,12 @@
1//! Tests and test utilities for completions.
2//!
3//! Most tests live in this module or its submodules unless for very specific completions like
4//! `attributes` or `lifetimes` where the completed concept is a distinct thing.
5//! Notable examples for completions that are being tested in this module's submodule are paths.
6
1mod item_list; 7mod item_list;
2mod use_tree; 8mod use_tree;
9mod items;
3 10
4use hir::{PrefixKind, Semantics}; 11use hir::{PrefixKind, Semantics};
5use ide_db::{ 12use ide_db::{
@@ -32,7 +39,7 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
32 }, 39 },
33}; 40};
34 41
35fn completion_list(code: &str) -> String { 42pub(crate) fn completion_list(code: &str) -> String {
36 completion_list_with_config(TEST_CONFIG, code) 43 completion_list_with_config(TEST_CONFIG, code)
37} 44}
38 45
diff --git a/crates/ide_completion/src/tests/items.rs b/crates/ide_completion/src/tests/items.rs
new file mode 100644
index 000000000..8dfb8221b
--- /dev/null
+++ b/crates/ide_completion/src/tests/items.rs
@@ -0,0 +1,127 @@
1//! Completions tests for item specifics overall.
2//!
3//! Except for use items which are tested in [super::use_tree] and mod declarations with are tested
4//! in [crate::completions::mod_].
5use expect_test::{expect, Expect};
6
7use crate::tests::completion_list;
8
9fn check(ra_fixture: &str, expect: Expect) {
10 let base = r#"#[rustc_builtin_macro]
11pub macro Clone {}
12enum Enum { Variant }
13struct Struct {}
14#[macro_export]
15macro_rules! foo {}
16mod bar {}
17const CONST: () = ();
18trait Trait {}
19"#;
20 let actual = completion_list(&format!("{}{}", base, ra_fixture));
21 expect.assert_eq(&actual)
22}
23
24#[test]
25fn target_type_or_trait_in_impl_block() {
26 check(
27 r#"
28impl Tra$0
29"#,
30 expect![[r##"
31 tt Trait
32 en Enum
33 st Struct
34 md bar
35 ma foo!(…) #[macro_export] macro_rules! foo
36 ma foo!(…) #[macro_export] macro_rules! foo
37 bt u32
38 bt bool
39 bt u8
40 bt isize
41 bt u16
42 bt u64
43 bt u128
44 bt f32
45 bt i128
46 bt i16
47 bt str
48 bt i64
49 bt char
50 bt f64
51 bt i32
52 bt i8
53 bt usize
54 "##]],
55 )
56}
57
58#[test]
59fn target_type_in_trait_impl_block() {
60 check(
61 r#"
62impl Trait for Str$0
63"#,
64 expect![[r##"
65 tt Trait
66 en Enum
67 st Struct
68 md bar
69 ma foo!(…) #[macro_export] macro_rules! foo
70 ma foo!(…) #[macro_export] macro_rules! foo
71 bt u32
72 bt bool
73 bt u8
74 bt isize
75 bt u16
76 bt u64
77 bt u128
78 bt f32
79 bt i128
80 bt i16
81 bt str
82 bt i64
83 bt char
84 bt f64
85 bt i32
86 bt i8
87 bt usize
88 "##]],
89 )
90}
91
92#[test]
93fn after_trait_name_in_trait_def() {
94 check(
95 r"trait A $0",
96 expect![[r#"
97 kw where
98 "#]],
99 );
100}
101
102#[test]
103fn after_trait_or_target_name_in_impl() {
104 check(
105 r"impl Trait $0",
106 expect![[r#"
107 kw where
108 kw for
109 "#]],
110 );
111}
112
113#[test]
114fn before_record_field() {
115 check(
116 r#"
117struct Foo {
118 $0
119 pub f: i32,
120}
121"#,
122 expect![[r#"
123 kw pub(crate)
124 kw pub
125 "#]],
126 )
127}