From 76ddface089886c88b8b29e3893119f38ef26aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 23 Jun 2020 09:41:43 +0300 Subject: Fix panic in split and merge import assists --- crates/ra_assists/src/handlers/merge_imports.rs | 12 +++++++++++- crates/ra_assists/src/handlers/split_import.rs | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index 972d16241..ac0b3035c 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs @@ -127,7 +127,7 @@ fn first_path(path: &ast::Path) -> ast::Path { #[cfg(test)] mod tests { - use crate::tests::check_assist; + use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; @@ -276,4 +276,14 @@ bar::baz}; ", ) } + + #[test] + fn test_empty_use() { + check_assist_not_applicable( + merge_imports, + r" +use std::<|> +fn main() {}", + ); + } } diff --git a/crates/ra_assists/src/handlers/split_import.rs b/crates/ra_assists/src/handlers/split_import.rs index c7a874480..38aa199a0 100644 --- a/crates/ra_assists/src/handlers/split_import.rs +++ b/crates/ra_assists/src/handlers/split_import.rs @@ -66,4 +66,14 @@ mod tests { fn issue4044() { check_assist_not_applicable(split_import, "use crate::<|>:::self;") } + + #[test] + fn test_empty_use() { + check_assist_not_applicable( + split_import, + r" +use std::<|> +fn main() {}", + ); + } } -- cgit v1.2.3