@@ -1640,6 +1640,40 @@ 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+ && let Some ( guar) = self . dcx ( ) . try_steal_modify_and_emit_err (
1652+ expr. span ,
1653+ StashKey :: StructLitNoType ,
1654+ |err| {
1655+ // The parser provided a sub-optimal `HasPlaceholders` suggestion for the type.
1656+ // We are typeck and have the real type, so remove that and suggest the actual type.
1657+ if let Ok ( suggestions) = & mut err. suggestions {
1658+ suggestions. clear ( ) ;
1659+ }
1660+
1661+ err. span_suggestion (
1662+ qpath. span ( ) ,
1663+ // FIXME(fmease): Make this translatable.
1664+ "replace it with the correct type" ,
1665+ // FIXME(fmease): This doesn't qualify paths within the type appropriately.
1666+ // FIXME(fmease): This doesn't use turbofish when emitting generic args.
1667+ // FIXME(fmease): Make the type suggestable.
1668+ ty. to_string ( ) ,
1669+ Applicability :: MaybeIncorrect ,
1670+ ) ;
1671+ } ,
1672+ )
1673+ {
1674+ return Ty :: new_error ( self . tcx , guar) ;
1675+ }
1676+
16431677 // Find the relevant variant
16441678 let ( variant, adt_ty) = match self . check_struct_path ( qpath, expr. hir_id ) {
16451679 Ok ( data) => data,
0 commit comments