From d7f182bd304d4c168e6950030196852a704dff8e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 29 Jan 2021 00:28:54 +0200 Subject: Forbid flyimport completions in use statements --- crates/completion/src/completions/flyimport.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'crates') 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) if !ctx.config.enable_imports_on_the_fly { return None; } - if ctx.attribute_under_caret.is_some() || ctx.mod_declaration_under_caret.is_some() { + if ctx.use_item_syntax.is_some() + || ctx.attribute_under_caret.is_some() + || ctx.mod_declaration_under_caret.is_some() + { return None; } let potential_import_name = { @@ -664,4 +667,22 @@ fn main() { "#]], ); } + + #[test] + fn no_completions_in_use_statements() { + check( + r#" +//- /lib.rs crate:dep +pub mod io { + pub fn stdin() {} +}; + +//- /main.rs crate:main deps:dep +use stdi$0 + +fn main() {} +"#, + expect![[]], + ); + } } -- cgit v1.2.3