Do not show flyimports in trait or impl declarations

This commit is contained in:
Kirill Bulatov 2021-04-15 11:50:47 +03:00
parent e131bfc747
commit 1c75d64c70

View File

@ -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#""#]],
);
}
}