@@ -628,7 +628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
628628 expr : & ' tcx hir:: Expr < ' tcx > ,
629629 ) -> Ty < ' tcx > {
630630 let hint = expected. only_has_type ( self ) . map_or ( NoExpectation , |ty| {
631- match ty . kind ( ) {
631+ match self . try_structurally_resolve_type ( expr . span , ty ) . kind ( ) {
632632 ty:: Ref ( _, ty, _) | ty:: RawPtr ( ty, _) => {
633633 if oprnd. is_syntactic_place_expr ( ) {
634634 // Places may legitimately have unsized types.
@@ -1293,7 +1293,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12931293 let cond_diverges = self . diverges . get ( ) ;
12941294 self . diverges . set ( Diverges :: Maybe ) ;
12951295
1296- let expected = orig_expected. adjust_for_branches ( self ) ;
1296+ let expected = orig_expected. try_structurally_resolve_and_adjust_for_branches ( self , sp ) ;
12971297 let then_ty = self . check_expr_with_expectation ( then_expr, expected) ;
12981298 let then_diverges = self . diverges . get ( ) ;
12991299 self . diverges . set ( Diverges :: Maybe ) ;
@@ -1354,8 +1354,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13541354 rhs : & ' tcx hir:: Expr < ' tcx > ,
13551355 span : Span ,
13561356 ) -> Ty < ' tcx > {
1357- let expected_ty = expected. coercion_target_type ( self , expr . span ) ;
1358- if expected_ty == self . tcx . types . bool {
1357+ let expected_ty = expected. only_has_type ( self ) ;
1358+ if expected_ty == Some ( self . tcx . types . bool ) {
13591359 let guar = self . expr_assign_expected_bool_error ( expr, lhs, rhs, span) ;
13601360 return Ty :: new_error ( self . tcx , guar) ;
13611361 }
@@ -1639,7 +1639,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16391639 let element_ty = if !args. is_empty ( ) {
16401640 let coerce_to = expected
16411641 . to_option ( self )
1642- . and_then ( |uty| match * uty. kind ( ) {
1642+ . and_then ( |uty| match * self . try_structurally_resolve_type ( expr . span , uty) . kind ( ) {
16431643 ty:: Array ( ty, _) | ty:: Slice ( ty) => Some ( ty) ,
16441644 _ => None ,
16451645 } )
0 commit comments