mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Merge #8526
8526: fix: Do not show flyimports in trait or impl declarations r=SomeoneToIgnore a=SomeoneToIgnore Part of https://github.com/rust-analyzer/rust-analyzer/issues/8518 Removes autoimport suggestions for the case: > inside trait definitions / impls (trait Trait {$0} / impl Foo {$0}), nothing except the fn, type and const keywords (and the full item completions for trait impls) should appear (currently many types and autoimport suggestions) Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
commit
042c248cc5
1 changed files with 50 additions and 0 deletions
|
@ -114,6 +114,8 @@ pub(crate) fn import_on_the_fly(acc: &mut Completions, ctx: &CompletionContext)
|
||||||
|| ctx.attribute_under_caret.is_some()
|
|| ctx.attribute_under_caret.is_some()
|
||||||
|| ctx.mod_declaration_under_caret.is_some()
|
|| ctx.mod_declaration_under_caret.is_some()
|
||||||
|| ctx.record_lit_syntax.is_some()
|
|| ctx.record_lit_syntax.is_some()
|
||||||
|
|| ctx.has_trait_parent
|
||||||
|
|| ctx.has_impl_parent
|
||||||
{
|
{
|
||||||
return None;
|
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#""#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue