diff options
author | Kirill Bulatov <[email protected]> | 2021-01-28 22:28:54 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-01-28 22:28:54 +0000 |
commit | d7f182bd304d4c168e6950030196852a704dff8e (patch) | |
tree | 539c21b61464dc10ff9f34762dc4decca9b6e803 /crates/completion/src/completions | |
parent | a3e4f07a8326cb86ec87c1a86002f284e83be3a3 (diff) |
Forbid flyimport completions in use statements
Diffstat (limited to 'crates/completion/src/completions')
-rw-r--r-- | crates/completion/src/completions/flyimport.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/crates/completion/src/completions/flyimport.rs b/crates/completion/src/completions/flyimport.rs index 6591127b1..9c6a5a40c 100644 --- a/crates/completion/src/completions/flyimport.rs +++ b/crates/completion/src/completions/flyimport.rs | |||
@@ -68,7 +68,10 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext) | |||
68 | if !ctx.config.enable_imports_on_the_fly { | 68 | if !ctx.config.enable_imports_on_the_fly { |
69 | return None; | 69 | return None; |
70 | } | 70 | } |
71 | if ctx.attribute_under_caret.is_some() || ctx.mod_declaration_under_caret.is_some() { | 71 | if ctx.use_item_syntax.is_some() |
72 | || ctx.attribute_under_caret.is_some() | ||
73 | || ctx.mod_declaration_under_caret.is_some() | ||
74 | { | ||
72 | return None; | 75 | return None; |
73 | } | 76 | } |
74 | let potential_import_name = { | 77 | let potential_import_name = { |
@@ -664,4 +667,22 @@ fn main() { | |||
664 | "#]], | 667 | "#]], |
665 | ); | 668 | ); |
666 | } | 669 | } |
670 | |||
671 | #[test] | ||
672 | fn no_completions_in_use_statements() { | ||
673 | check( | ||
674 | r#" | ||
675 | //- /lib.rs crate:dep | ||
676 | pub mod io { | ||
677 | pub fn stdin() {} | ||
678 | }; | ||
679 | |||
680 | //- /main.rs crate:main deps:dep | ||
681 | use stdi$0 | ||
682 | |||
683 | fn main() {} | ||
684 | "#, | ||
685 | expect![[]], | ||
686 | ); | ||
687 | } | ||
667 | } | 688 | } |