1+ //! Handle syntactic aspects of inserting a new `use`.
12use std:: iter:: { self , successors} ;
23
34use algo:: skip_trivia_token;
@@ -10,7 +11,6 @@ use syntax::{
1011 ast:: { self , make, AstNode } ,
1112 Direction , InsertPosition , SyntaxElement , SyntaxNode , T ,
1213} ;
13-
1414use test_utils:: mark;
1515
1616#[ derive( Debug ) ]
@@ -55,7 +55,7 @@ impl ImportScope {
5555 fn first_insert_pos ( & self ) -> ( InsertPosition < SyntaxElement > , AddBlankLine ) {
5656 match self {
5757 ImportScope :: File ( _) => ( InsertPosition :: First , AddBlankLine :: AfterTwice ) ,
58- // don't insert the impotrs before the item lists curly brace
58+ // don't insert the imports before the item list's opening curly brace
5959 ImportScope :: Module ( item_list) => item_list
6060 . l_curly_token ( )
6161 . map ( |b| ( InsertPosition :: After ( b. into ( ) ) , AddBlankLine :: Around ) )
@@ -64,7 +64,7 @@ impl ImportScope {
6464 }
6565
6666 fn insert_pos_after_inner_attribute ( & self ) -> ( InsertPosition < SyntaxElement > , AddBlankLine ) {
67- // check if the scope has a inner attributes, we dont want to insert in front of it
67+ // check if the scope has inner attributes, we dont want to insert in front of them
6868 match self
6969 . as_syntax_node ( )
7070 . children ( )
@@ -119,7 +119,7 @@ pub(crate) fn insert_use(
119119 }
120120
121121 if let ident_level @ 1 ..=usize:: MAX = scope. indent_level ( ) . 0 as usize {
122- // TODO : this alone doesnt properly re-align all cases
122+ // FIXME : this alone doesnt properly re-align all cases
123123 buf. push ( make:: tokens:: whitespace ( & " " . repeat ( 4 * ident_level) ) . into ( ) ) ;
124124 }
125125 buf. push ( use_item. syntax ( ) . clone ( ) . into ( ) ) ;
@@ -530,8 +530,6 @@ fn main() {}",
530530
531531 #[ test]
532532 fn insert_after_inner_attr ( ) {
533- // empty files will get two trailing newlines
534- // this is due to the test case insert_no_imports above
535533 check_full (
536534 "foo::bar" ,
537535 r"#![allow(unused_imports)]" ,
@@ -543,8 +541,6 @@ use foo::bar;",
543541
544542 #[ test]
545543 fn insert_after_inner_attr2 ( ) {
546- // empty files will get two trailing newlines
547- // this is due to the test case insert_no_imports above
548544 check_full (
549545 "foo::bar" ,
550546 r"#![allow(unused_imports)]
@@ -647,6 +643,16 @@ use std::io;",
647643 )
648644 }
649645
646+ #[ test]
647+ fn merge_groups_skip_pub_crate ( ) {
648+ check_full (
649+ "std::io" ,
650+ r"pub(crate) use std::fmt::{Result, Display};" ,
651+ r"pub(crate) use std::fmt::{Result, Display};
652+ use std::io;" ,
653+ )
654+ }
655+
650656 #[ test]
651657 #[ ignore] // FIXME: Support this
652658 fn split_out_merge ( ) {
0 commit comments