@@ -1613,9 +1613,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1613
1613
self . demand_coerce_diag ( & field. expr , ty, field_type, None , AllowTwoPhase :: No ) ;
1614
1614
1615
1615
if let Some ( mut diag) = diag {
1616
- if idx == ast_fields. len ( ) - 1 && remaining_fields. is_empty ( ) {
1617
- self . suggest_fru_from_range ( field, variant, substs, & mut diag) ;
1616
+ if idx == ast_fields. len ( ) - 1 {
1617
+ if remaining_fields. is_empty ( ) {
1618
+ self . suggest_fru_from_range ( field, variant, substs, & mut diag) ;
1619
+ } else {
1620
+ diag. stash ( diag. sort_span , StashKey :: RangeLit )
1621
+ }
1618
1622
}
1623
+
1619
1624
diag. emit ( ) ;
1620
1625
}
1621
1626
}
@@ -1807,7 +1812,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1807
1812
variant : & ' tcx ty:: VariantDef ,
1808
1813
ast_fields : & ' tcx [ hir:: ExprField < ' tcx > ] ,
1809
1814
substs : SubstsRef < ' tcx > ,
1810
- ) {
1815
+ ) -> bool {
1811
1816
let len = remaining_fields. len ( ) ;
1812
1817
1813
1818
let mut displayable_field_names: Vec < & str > =
@@ -1844,7 +1849,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1844
1849
) ;
1845
1850
err. span_label ( span, format ! ( "missing {remaining_fields_names}{truncated_fields_error}" ) ) ;
1846
1851
1847
- if let Some ( last) = ast_fields. last ( ) {
1852
+ if let Some ( last) = ast_fields. last ( ) && self . suggest_fru_from_range ( ) {
1853
+ // unstash and cancel
1854
+ let un = self . tcx . sess . diagnostic ( ) . steal_diagnostic ( span, StashKey :: RangeLit ) . unwrap ( ) ;
1855
+ un. cancel ( ) ;
1848
1856
self . suggest_fru_from_range ( last, variant, substs, & mut err) ;
1849
1857
}
1850
1858
0 commit comments