@@ -625,7 +625,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
625625 expr : & ' tcx hir:: Expr < ' tcx > ,
626626 ) -> Ty < ' tcx > {
627627 let hint = expected. only_has_type ( self ) . map_or ( NoExpectation , |ty| {
628- match ty . kind ( ) {
628+ match self . try_structurally_resolve_type ( expr . span , ty ) . kind ( ) {
629629 ty:: Ref ( _, ty, _) | ty:: RawPtr ( ty, _) => {
630630 if oprnd. is_syntactic_place_expr ( ) {
631631 // Places may legitimately have unsized types.
@@ -1290,7 +1290,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12901290 let cond_diverges = self . diverges . get ( ) ;
12911291 self . diverges . set ( Diverges :: Maybe ) ;
12921292
1293- let expected = orig_expected. adjust_for_branches ( self , sp) ;
1293+ let expected = orig_expected. try_structurally_resolve_and_adjust_for_branches ( self , sp) ;
12941294 let then_ty = self . check_expr_with_expectation ( then_expr, expected) ;
12951295 let then_diverges = self . diverges . get ( ) ;
12961296 self . diverges . set ( Diverges :: Maybe ) ;
@@ -1351,8 +1351,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13511351 rhs : & ' tcx hir:: Expr < ' tcx > ,
13521352 span : Span ,
13531353 ) -> Ty < ' tcx > {
1354- let expected_ty = expected. coercion_target_type ( self , expr . span ) ;
1355- if expected_ty == self . tcx . types . bool {
1354+ let expected_ty = expected. only_has_type ( self ) ;
1355+ if expected_ty == Some ( self . tcx . types . bool ) {
13561356 let guar = self . expr_assign_expected_bool_error ( expr, lhs, rhs, span) ;
13571357 return Ty :: new_error ( self . tcx , guar) ;
13581358 }
@@ -1636,7 +1636,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16361636 let element_ty = if !args. is_empty ( ) {
16371637 let coerce_to = expected
16381638 . to_option ( self )
1639- . and_then ( |uty| match * uty. kind ( ) {
1639+ . and_then ( |uty| match * self . try_structurally_resolve_type ( expr . span , uty) . kind ( ) {
16401640 ty:: Array ( ty, _) | ty:: Slice ( ty) => Some ( ty) ,
16411641 _ => None ,
16421642 } )
0 commit comments