diff options
| author | David Barsky <me@davidbarsky.com> | 2024-05-22 16:16:19 -0400 |
|---|---|---|
| committer | David Barsky <me@davidbarsky.com> | 2024-05-22 16:16:20 -0400 |
| commit | f2c3ef77b1976eee67ae88ac12cbd1eb4e2da398 (patch) | |
| tree | 08627cfd0b426a6d9c3af8e1ee38036d9920900d /src/tools/rust-analyzer/crates/ide-completion | |
| parent | 56ce7e0e06cf2888e7b3d9d1f03ab353d9a3721b (diff) | |
fix: ensure implied bounds from associated types are considered in autocomplete
Diffstat (limited to 'src/tools/rust-analyzer/crates/ide-completion')
| -rw-r--r-- | src/tools/rust-analyzer/crates/ide-completion/src/tests/flyimport.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/tests/flyimport.rs b/src/tools/rust-analyzer/crates/ide-completion/src/tests/flyimport.rs index d2227d23cd7..abffa73c3b4 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/tests/flyimport.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/tests/flyimport.rs @@ -473,6 +473,47 @@ fn main() { } #[test] +fn trait_completions_handle_associated_types() { + let fixture = r#" +//- /foo.rs crate:foo +pub trait NotInScope { + fn not_in_scope(&self); +} + +pub trait Wrapper { + type Inner: NotInScope; + fn inner(&self) -> Self::Inner; +} + +//- /main.rs crate:main deps:foo +use foo::Wrapper; + +fn completion<T: Wrapper>(whatever: T) { + whatever.inner().$0 +} +"#; + + check( + fixture, + expect![[r#" + me not_in_scope() (use foo::NotInScope) fn(&self) + "#]], + ); + + check_edit( + "not_in_scope", + fixture, + r#" +use foo::{NotInScope, Wrapper}; + +fn completion<T: Wrapper>(whatever: T) { + whatever.inner().not_in_scope()$0 +} +"#, + ); +} + +#[test] fn trait_method_fuzzy_completion_aware_of_unit_type() { let fixture = r#" //- /test_trait.rs crate:test_trait |
