@@ -4,6 +4,7 @@ use rustc_hash::FxHashMap;
44use hir:: { Adt , ModuleDef , PathResolution , Semantics , Struct } ;
55use ide_db:: RootDatabase ;
66use syntax:: { algo, ast, match_ast, AstNode , SyntaxKind , SyntaxKind :: * , SyntaxNode } ;
7+ use test_utils:: mark;
78
89use crate :: { AssistContext , AssistId , AssistKind , Assists } ;
910
@@ -38,6 +39,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
3839 } ) ;
3940
4041 if sorted_fields == fields {
42+ mark:: hit!( reorder_sorted_fields) ;
4143 return None ;
4244 }
4345
@@ -107,22 +109,25 @@ fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashM
107109
108110#[ cfg( test) ]
109111mod tests {
112+ use test_utils:: mark;
113+
110114 use crate :: tests:: { check_assist, check_assist_not_applicable} ;
111115
112116 use super :: * ;
113117
114118 #[ test]
115- fn not_applicable_if_sorted ( ) {
119+ fn reorder_sorted_fields ( ) {
120+ mark:: check!( reorder_sorted_fields) ;
116121 check_assist_not_applicable (
117122 reorder_fields,
118123 r#"
119- struct Foo {
120- foo: i32,
121- bar: i32,
122- }
124+ struct Foo {
125+ foo: i32,
126+ bar: i32,
127+ }
123128
124- const test: Foo = <|>Foo { foo: 0, bar: 0 };
125- "#,
129+ const test: Foo = <|>Foo { foo: 0, bar: 0 };
130+ "# ,
126131 )
127132 }
128133
@@ -131,9 +136,9 @@ mod tests {
131136 check_assist_not_applicable (
132137 reorder_fields,
133138 r#"
134- struct Foo {};
135- const test: Foo = <|>Foo {}
136- "#,
139+ struct Foo {};
140+ const test: Foo = <|>Foo {}
141+ "# ,
137142 )
138143 }
139144
@@ -142,13 +147,13 @@ mod tests {
142147 check_assist (
143148 reorder_fields,
144149 r#"
145- struct Foo {foo: i32, bar: i32};
146- const test: Foo = <|>Foo {bar: 0, foo: 1}
147- "#,
150+ struct Foo {foo: i32, bar: i32};
151+ const test: Foo = <|>Foo {bar: 0, foo: 1}
152+ "# ,
148153 r#"
149- struct Foo {foo: i32, bar: i32};
150- const test: Foo = Foo {foo: 1, bar: 0}
151- "#,
154+ struct Foo {foo: i32, bar: i32};
155+ const test: Foo = Foo {foo: 1, bar: 0}
156+ "# ,
152157 )
153158 }
154159
@@ -157,25 +162,25 @@ mod tests {
157162 check_assist (
158163 reorder_fields,
159164 r#"
160- struct Foo { foo: i64, bar: i64, baz: i64 }
165+ struct Foo { foo: i64, bar: i64, baz: i64 }
161166
162- fn f(f: Foo) -> {
163- match f {
164- <|>Foo { baz: 0, ref mut bar, .. } => (),
165- _ => ()
166- }
167- }
168- "#,
167+ fn f(f: Foo) -> {
168+ match f {
169+ <|>Foo { baz: 0, ref mut bar, .. } => (),
170+ _ => ()
171+ }
172+ }
173+ "# ,
169174 r#"
170- struct Foo { foo: i64, bar: i64, baz: i64 }
175+ struct Foo { foo: i64, bar: i64, baz: i64 }
171176
172- fn f(f: Foo) -> {
173- match f {
174- Foo { ref mut bar, baz: 0, .. } => (),
175- _ => ()
176- }
177- }
178- "#,
177+ fn f(f: Foo) -> {
178+ match f {
179+ Foo { ref mut bar, baz: 0, .. } => (),
180+ _ => ()
181+ }
182+ }
183+ "# ,
179184 )
180185 }
181186
@@ -184,39 +189,39 @@ mod tests {
184189 check_assist (
185190 reorder_fields,
186191 r#"
187- struct Foo {
188- foo: String,
189- bar: String,
190- }
192+ struct Foo {
193+ foo: String,
194+ bar: String,
195+ }
191196
192- impl Foo {
193- fn new() -> Foo {
194- let foo = String::new();
195- <|>Foo {
196- bar: foo.clone(),
197- extra: "Extra field",
198- foo,
199- }
200- }
201- }
202- "#,
197+ impl Foo {
198+ fn new() -> Foo {
199+ let foo = String::new();
200+ <|>Foo {
201+ bar: foo.clone(),
202+ extra: "Extra field",
203+ foo,
204+ }
205+ }
206+ }
207+ "# ,
203208 r#"
204- struct Foo {
205- foo: String,
206- bar: String,
207- }
209+ struct Foo {
210+ foo: String,
211+ bar: String,
212+ }
208213
209- impl Foo {
210- fn new() -> Foo {
211- let foo = String::new();
212- Foo {
213- foo,
214- bar: foo.clone(),
215- extra: "Extra field",
216- }
217- }
218- }
219- "#,
214+ impl Foo {
215+ fn new() -> Foo {
216+ let foo = String::new();
217+ Foo {
218+ foo,
219+ bar: foo.clone(),
220+ extra: "Extra field",
221+ }
222+ }
223+ }
224+ "# ,
220225 )
221226 }
222227}
0 commit comments