This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +78
-0
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +78
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,84 @@ fn foo(bar: Bar) {
187187 )
188188 }
189189
190+ #[ test]
191+ fn fill_fields_struct_generated_by_macro ( ) {
192+ check_assist (
193+ fill_record_pattern_fields,
194+ r#"
195+ macro_rules! position {
196+ ($t: ty) => {
197+ struct Pos {x: $t, y: $t}
198+ };
199+ }
200+
201+ position!(usize);
202+
203+ fn macro_call(pos: Pos) {
204+ let Pos { ..$0 } = pos;
205+ }
206+ "# ,
207+ r#"
208+ macro_rules! position {
209+ ($t: ty) => {
210+ struct Pos {x: $t, y: $t}
211+ };
212+ }
213+
214+ position!(usize);
215+
216+ fn macro_call(pos: Pos) {
217+ let Pos { x, y } = pos;
218+ }
219+ "# ,
220+ ) ;
221+ }
222+
223+ #[ test]
224+ fn fill_fields_enum_generated_by_macro ( ) {
225+ check_assist (
226+ fill_record_pattern_fields,
227+ r#"
228+ macro_rules! enum_gen {
229+ ($t: ty) => {
230+ enum Foo {
231+ A($t),
232+ B{x: $t, y: $t},
233+ }
234+ };
235+ }
236+
237+ enum_gen!(usize);
238+
239+ fn macro_call(foo: Foo) {
240+ match foo {
241+ Foo::A(_) => false,
242+ Foo::B{ ..$0 } => true,
243+ }
244+ }
245+ "# ,
246+ r#"
247+ macro_rules! enum_gen {
248+ ($t: ty) => {
249+ enum Foo {
250+ A($t),
251+ B{x: $t, y: $t},
252+ }
253+ };
254+ }
255+
256+ enum_gen!(usize);
257+
258+ fn macro_call(foo: Foo) {
259+ match foo {
260+ Foo::A(_) => false,
261+ Foo::B{ x, y } => true,
262+ }
263+ }
264+ "# ,
265+ ) ;
266+ }
267+
190268 #[ test]
191269 fn not_applicable_when_not_in_ellipsis ( ) {
192270 check_assist_not_applicable (
You can’t perform that action at this time.
0 commit comments