mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 12:04:43 +00:00 
			
		
		
		
	Handle missing fields diagnostics
This commit is contained in:
		
							parent
							
								
									7de0b2e75a
								
							
						
					
					
						commit
						e6a103ae50
					
				
					 11 changed files with 59 additions and 12 deletions
				
			
		|  | @ -547,8 +547,8 @@ pub fn record_literal_missing_fields( | |||
|     id: ExprId, | ||||
|     expr: &Expr, | ||||
| ) -> Option<(VariantId, Vec<LocalFieldId>, /*exhaustive*/ bool)> { | ||||
|     let (fields, exhaustive) = match expr { | ||||
|         Expr::RecordLit { fields, spread, .. } => (fields, spread.is_none()), | ||||
|     let (fields, exhaustive, ellipsis) = match expr { | ||||
|         Expr::RecordLit { fields, spread, ellipsis, .. } => (fields, spread.is_none(), *ellipsis), | ||||
|         _ => return None, | ||||
|     }; | ||||
| 
 | ||||
|  | @ -563,7 +563,13 @@ pub fn record_literal_missing_fields( | |||
|     let missed_fields: Vec<LocalFieldId> = variant_data | ||||
|         .fields() | ||||
|         .iter() | ||||
|         .filter_map(|(f, d)| if specified_fields.contains(&d.name) { None } else { Some(f) }) | ||||
|         .filter_map(|(f, d)| { | ||||
|             if (ellipsis && d.has_default) || specified_fields.contains(&d.name) { | ||||
|                 None | ||||
|             } else { | ||||
|                 Some(f) | ||||
|             } | ||||
|         }) | ||||
|         .collect(); | ||||
|     if missed_fields.is_empty() { | ||||
|         return None; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Shoyu Vanilla
						Shoyu Vanilla