aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-28 22:31:34 +0000
committerGitHub <[email protected]>2021-01-28 22:31:34 +0000
commit0ac4a8f35497718a5d17f74e0dd3ef36227222cc (patch)
tree539c21b61464dc10ff9f34762dc4decca9b6e803 /crates
parenta3e4f07a8326cb86ec87c1a86002f284e83be3a3 (diff)
parentd7f182bd304d4c168e6950030196852a704dff8e (diff)
Merge #7487
7487: Forbid flyimport completions in use statements r=SomeoneToIgnore a=SomeoneToIgnore Closes #7469 Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/completion/src/completions/flyimport.rs23
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
676pub mod io {
677 pub fn stdin() {}
678};
679
680//- /main.rs crate:main deps:dep
681use stdi$0
682
683fn main() {}
684"#,
685 expect![[]],
686 );
687 }
667} 688}