From aa64a84b493aa9c0b22f36b472a445d622cd2172 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 7 Feb 2020 15:12:51 +0100 Subject: Cleanups --- crates/ra_assists/src/assists/auto_import.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/assists/auto_import.rs b/crates/ra_assists/src/assists/auto_import.rs index 18ea98105..84b5474f9 100644 --- a/crates/ra_assists/src/assists/auto_import.rs +++ b/crates/ra_assists/src/assists/auto_import.rs @@ -9,6 +9,7 @@ use crate::{ assist_ctx::{ActionBuilder, Assist, AssistCtx}, auto_import_text_edit, AssistId, }; +use std::collections::BTreeSet; // Assist: auto_import // @@ -60,7 +61,8 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option { .filter_map(|module_def| module_with_name_to_import.find_use_path(ctx.db, module_def)) .filter(|use_path| !use_path.segments.is_empty()) .take(20) - .collect::>(); + .collect::>(); + if proposed_imports.is_empty() { return None; } @@ -82,9 +84,10 @@ fn import_to_action(import: ModPath, position: &SyntaxNode, anchor: &SyntaxNode) #[cfg(test)] mod tests { - use super::*; use crate::helpers::{check_assist, check_assist_not_applicable}; + use super::*; + #[test] fn applicable_when_found_an_import() { check_assist( -- cgit v1.2.3