Skip to content

Commit 1c75d64

Browse files
Do not show flyimports in trait or impl declarations
1 parent e131bfc commit 1c75d64

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

crates/ide_completion/src/completions/flyimport.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext)
114114
|| ctx.attribute_under_caret.is_some()
115115
|| ctx.mod_declaration_under_caret.is_some()
116116
|| ctx.record_lit_syntax.is_some()
117+
|| ctx.has_trait_parent
118+
|| ctx.has_impl_parent
117119
{
118120
return None;
119121
}
@@ -1077,4 +1079,52 @@ fn main() {
10771079
"#]],
10781080
);
10791081
}
1082+
1083+
#[test]
1084+
fn no_flyimports_in_traits_and_impl_declarations() {
1085+
check(
1086+
r#"
1087+
mod m {
1088+
pub fn some_fn() -> i32 {
1089+
42
1090+
}
1091+
}
1092+
trait Foo {
1093+
som$0
1094+
}
1095+
"#,
1096+
expect![[r#""#]],
1097+
);
1098+
1099+
check(
1100+
r#"
1101+
mod m {
1102+
pub fn some_fn() -> i32 {
1103+
42
1104+
}
1105+
}
1106+
struct Foo;
1107+
impl Foo {
1108+
som$0
1109+
}
1110+
"#,
1111+
expect![[r#""#]],
1112+
);
1113+
1114+
check(
1115+
r#"
1116+
mod m {
1117+
pub fn some_fn() -> i32 {
1118+
42
1119+
}
1120+
}
1121+
struct Foo;
1122+
trait Bar {}
1123+
impl Bar for Foo {
1124+
som$0
1125+
}
1126+
"#,
1127+
expect![[r#""#]],
1128+
);
1129+
}
10801130
}

0 commit comments

Comments
 (0)