@@ -628,7 +628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
628
628
expr : & ' tcx hir:: Expr < ' tcx > ,
629
629
) -> Ty < ' tcx > {
630
630
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 ( ) {
632
632
ty:: Ref ( _, ty, _) | ty:: RawPtr ( ty, _) => {
633
633
if oprnd. is_syntactic_place_expr ( ) {
634
634
// Places may legitimately have unsized types.
@@ -1293,7 +1293,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1293
1293
let cond_diverges = self . diverges . get ( ) ;
1294
1294
self . diverges . set ( Diverges :: Maybe ) ;
1295
1295
1296
- let expected = orig_expected. adjust_for_branches ( self ) ;
1296
+ let expected = orig_expected. try_structurally_resolve_and_adjust_for_branches ( self , sp ) ;
1297
1297
let then_ty = self . check_expr_with_expectation ( then_expr, expected) ;
1298
1298
let then_diverges = self . diverges . get ( ) ;
1299
1299
self . diverges . set ( Diverges :: Maybe ) ;
@@ -1354,8 +1354,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1354
1354
rhs : & ' tcx hir:: Expr < ' tcx > ,
1355
1355
span : Span ,
1356
1356
) -> 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 ) {
1359
1359
let guar = self . expr_assign_expected_bool_error ( expr, lhs, rhs, span) ;
1360
1360
return Ty :: new_error ( self . tcx , guar) ;
1361
1361
}
@@ -1639,7 +1639,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1639
1639
let element_ty = if !args. is_empty ( ) {
1640
1640
let coerce_to = expected
1641
1641
. to_option ( self )
1642
- . and_then ( |uty| match * uty. kind ( ) {
1642
+ . and_then ( |uty| match * self . try_structurally_resolve_type ( expr . span , uty) . kind ( ) {
1643
1643
ty:: Array ( ty, _) | ty:: Slice ( ty) => Some ( ty) ,
1644
1644
_ => None ,
1645
1645
} )
0 commit comments