diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-02 10:38:03 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-02 10:38:03 +0000 |
commit | dce7dc44be948bb6b73b79ce284ec2eb83811ae8 (patch) | |
tree | 4e223570d7ed75e24156d5452ac79ef1f1c53bf4 /crates/ra_assists/src/assists | |
parent | 96bd4f5704f447800067ce69d50ab8b4b2315fdb (diff) | |
parent | d3188769e41a051df7f02395b43f11e5cedede0b (diff) |
Merge #2978
2978: Auto import functions r=flodiebold a=SomeoneToIgnore
A follow up for https://github.com/rust-analyzer/rust-analyzer/pull/2887#issuecomment-577832601
I've used the logic for conversion from the https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_hir_def/src/item_scope.rs#L169 method.
I'm not fond of how the conversion is implemented and for my needs, I can simply replace the `hir_def::item_scope::ItemInNs::Types(item.into())` with `hir_def::item_scope::ItemInNs::Values(item.into())` and it will work, so I can use this approach instead, if you find it a better one.
Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/assists')
-rw-r--r-- | crates/ra_assists/src/assists/auto_import.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/ra_assists/src/assists/auto_import.rs b/crates/ra_assists/src/assists/auto_import.rs index 932a52bff..8c483e2da 100644 --- a/crates/ra_assists/src/assists/auto_import.rs +++ b/crates/ra_assists/src/assists/auto_import.rs | |||
@@ -211,4 +211,28 @@ mod tests { | |||
211 | }", | 211 | }", |
212 | ); | 212 | ); |
213 | } | 213 | } |
214 | |||
215 | #[test] | ||
216 | fn function_import() { | ||
217 | check_assist_with_imports_locator( | ||
218 | auto_import, | ||
219 | TestImportsLocator::new, | ||
220 | r" | ||
221 | test_function<|> | ||
222 | |||
223 | pub mod PubMod { | ||
224 | pub fn test_function() {}; | ||
225 | } | ||
226 | ", | ||
227 | r" | ||
228 | use PubMod::test_function; | ||
229 | |||
230 | test_function<|> | ||
231 | |||
232 | pub mod PubMod { | ||
233 | pub fn test_function() {}; | ||
234 | } | ||
235 | ", | ||
236 | ); | ||
237 | } | ||
214 | } | 238 | } |