]> git.lizzy.rs Git - rust.git/commitdiff
Use mark to check that paths that are too long will not be merged
authorLukas Wirth <lukastw97@gmail.com>
Wed, 2 Sep 2020 17:34:01 +0000 (19:34 +0200)
committerLukas Wirth <lukastw97@gmail.com>
Thu, 3 Sep 2020 16:36:07 +0000 (18:36 +0200)
crates/assists/src/utils/insert_use.rs

index dbe2dfdcb1b1b9627e76b3f52e7365bbf9bbecae..8842068e6508adabdb6f28e2689d5a33dc69f0dd 100644 (file)
@@ -10,6 +10,7 @@
 };
 
 use crate::assist_context::AssistContext;
+use test_utils::mark;
 
 /// Determines the containing syntax node in which to insert a `use` statement affecting `position`.
 pub(crate) fn find_insert_use_container(
@@ -126,6 +127,7 @@ pub fn try_merge_trees(
     if merge_behaviour == MergeBehaviour::Last
         && (use_tree_list_is_nested(&lhs_tl) || use_tree_list_is_nested(&rhs_tl))
     {
+        mark::hit!(test_last_merge_too_long);
         return None;
     }
 
@@ -586,6 +588,17 @@ fn merge_self_glob() {
         )
     }
 
+    #[test]
+    fn merge_last_too_long() {
+        mark::check!(test_last_merge_too_long);
+        check_last(
+            "foo::bar",
+            r"use foo::bar::baz::Qux;",
+            r"use foo::bar::baz::Qux;
+use foo::bar;",
+        );
+    }
+
     fn check(
         path: &str,
         ra_fixture_before: &str,