@@ -1640,6 +1640,41 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16401640 fields : & ' tcx [ hir:: ExprField < ' tcx > ] ,
16411641 base_expr : & ' tcx Option < & ' tcx hir:: Expr < ' tcx > > ,
16421642 ) -> Ty < ' tcx > {
1643+ // FIXME(fmease): Move this into separate method.
1644+ // FIXME(fmease): This doesn't get called given `(_ { x: () }).x` (`hir::Field`).
1645+ // Figure out why.
1646+ if let QPath :: Resolved ( None , hir:: Path { res : Res :: Err , segments, .. } ) = qpath
1647+ && let [ segment] = segments
1648+ && segment. ident . name == kw:: Empty
1649+ && let Expectation :: ExpectHasType ( ty) = expected
1650+ && ty. is_adt ( )
1651+ {
1652+ if let Some ( guar) = self . dcx ( ) . try_steal_modify_and_emit_err (
1653+ expr. span ,
1654+ StashKey :: StructLitNoType ,
1655+ |err| {
1656+ // The parser provided a sub-optimal `HasPlaceholders` suggestion for the type.
1657+ // We are typeck and have the real type, so remove that and suggest the actual type.
1658+ if let Ok ( suggestions) = & mut err. suggestions {
1659+ suggestions. clear ( ) ;
1660+ }
1661+
1662+ err. span_suggestion (
1663+ qpath. span ( ) ,
1664+ // FIXME(fmease): Make this translatable.
1665+ "replace it with the correct type" ,
1666+ // FIXME(fmease): This doesn't qualify paths within the type appropriately.
1667+ // FIXME(fmease): This doesn't use turbofish when emitting generic args.
1668+ // FIXME(fmease): Make the type suggestable.
1669+ ty. to_string ( ) ,
1670+ Applicability :: MaybeIncorrect ,
1671+ ) ;
1672+ } ,
1673+ ) {
1674+ return Ty :: new_error ( self . tcx , guar) ;
1675+ }
1676+ }
1677+
16431678 // Find the relevant variant
16441679 let ( variant, adt_ty) = match self . check_struct_path ( qpath, expr. hir_id ) {
16451680 Ok ( data) => data,
0 commit comments