From 1c75d64c70f72783dc65e5376d01c615b05f18b5 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 15 Apr 2021 11:50:47 +0300 Subject: Do not show flyimports in trait or impl declarations --- crates/ide_completion/src/completions/flyimport.rs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'crates') diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index 9ace13e41..5e61ecb4d 100644 --- a/crates/ide_completion/src/completions/flyimport.rs +++ b/crates/ide_completion/src/completions/flyimport.rs @@ -114,6 +114,8 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext) || ctx.attribute_under_caret.is_some() || ctx.mod_declaration_under_caret.is_some() || ctx.record_lit_syntax.is_some() + || ctx.has_trait_parent + || ctx.has_impl_parent { return None; } @@ -1077,4 +1079,52 @@ fn main() { "#]], ); } + + #[test] + fn no_flyimports_in_traits_and_impl_declarations() { + check( + r#" +mod m { + pub fn some_fn() -> i32 { + 42 + } +} +trait Foo { + som$0 +} +"#, + expect![[r#""#]], + ); + + check( + r#" +mod m { + pub fn some_fn() -> i32 { + 42 + } +} +struct Foo; +impl Foo { + som$0 +} +"#, + expect![[r#""#]], + ); + + check( + r#" +mod m { + pub fn some_fn() -> i32 { + 42 + } +} +struct Foo; +trait Bar {} +impl Bar for Foo { + som$0 +} +"#, + expect![[r#""#]], + ); + } } -- cgit v1.2.3