mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-28 02:29:44 +00:00 
			
		
		
		
	Merge pull request #20730 from A4-Tacks/migrate-expand-rest-pat
Migrate `expand_record_rest_pattern` assist to use `SyntaxEditor`
This commit is contained in:
		
						commit
						f6cf3035c3
					
				
					 2 changed files with 11 additions and 12 deletions
				
			
		|  | @ -53,18 +53,17 @@ fn expand_record_rest_pattern( | |||
|         |builder| { | ||||
|             let make = SyntaxFactory::with_mappings(); | ||||
|             let mut editor = builder.make_editor(rest_pat.syntax()); | ||||
|             let new_field_list = make.record_pat_field_list(old_field_list.fields(), None); | ||||
|             for (f, _) in missing_fields.iter() { | ||||
|                 let field = make.record_pat_field_shorthand( | ||||
|             let new_fields = old_field_list.fields().chain(missing_fields.iter().map(|(f, _)| { | ||||
|                 make.record_pat_field_shorthand( | ||||
|                     make.ident_pat( | ||||
|                         false, | ||||
|                         false, | ||||
|                         make.name(&f.name(ctx.sema.db).display_no_db(edition).to_smolstr()), | ||||
|                     ) | ||||
|                     .into(), | ||||
|                 ); | ||||
|                 new_field_list.add_field(field); | ||||
|             } | ||||
|                 ) | ||||
|             })); | ||||
|             let new_field_list = make.record_pat_field_list(new_fields, None); | ||||
| 
 | ||||
|             editor.replace(old_field_list.syntax(), new_field_list.syntax()); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Shoyu Vanilla (Flint)
						Shoyu Vanilla (Flint)