From 03b77b03fefa4dc260b5a63223db253706d41ca8 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 14 Oct 2020 01:39:58 +0200 Subject: Fix stackoverflow in insert_use::recursive_merge --- crates/assists/src/handlers/merge_imports.rs | 14 ++++++++++++++ .../src/handlers/replace_qualified_name_with_use.rs | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'crates/assists/src/handlers') diff --git a/crates/assists/src/handlers/merge_imports.rs b/crates/assists/src/handlers/merge_imports.rs index fe33cee53..fd9c9e03c 100644 --- a/crates/assists/src/handlers/merge_imports.rs +++ b/crates/assists/src/handlers/merge_imports.rs @@ -72,6 +72,20 @@ mod tests { use super::*; + #[test] + fn test_merge_equal() { + check_assist( + merge_imports, + r" +use std::fmt<|>::{Display, Debug}; +use std::fmt::{Display, Debug}; +", + r" +use std::fmt::{Debug, Display}; +", + ) + } + #[test] fn test_merge_first() { check_assist( diff --git a/crates/assists/src/handlers/replace_qualified_name_with_use.rs b/crates/assists/src/handlers/replace_qualified_name_with_use.rs index e95b971a4..c50bc7604 100644 --- a/crates/assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/assists/src/handlers/replace_qualified_name_with_use.rs @@ -123,6 +123,23 @@ mod tests { use super::*; + #[test] + fn test_replace_already_imported() { + check_assist( + replace_qualified_name_with_use, + r"use std::fs; + +fn main() { + std::f<|>s::Path +}", + r"use std::fs; + +fn main() { + fs::Path +}", + ) + } + #[test] fn test_replace_add_use_no_anchor() { check_assist( -- cgit v1.2.3