@@ -2469,59 +2469,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2469
2469
}
2470
2470
}
2471
2471
2472
- fn is_place_expr ( & self , expr : & hir:: Expr ) -> bool {
2473
- match expr. node {
2474
- hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( _, ref path) ) => {
2475
- match path. def {
2476
- Def :: Local ( ..) | Def :: Upvar ( ..) | Def :: Static ( ..) | Def :: Err => true ,
2477
- _ => false ,
2478
- }
2479
- }
2480
-
2481
- hir:: ExprKind :: Type ( ref e, _) => {
2482
- self . is_place_expr ( e)
2483
- }
2484
-
2485
- hir:: ExprKind :: Unary ( hir:: UnDeref , _) |
2486
- hir:: ExprKind :: Field ( ..) |
2487
- hir:: ExprKind :: Index ( ..) => {
2488
- true
2489
- }
2490
-
2491
- // Partially qualified paths in expressions can only legally
2492
- // refer to associated items which are always rvalues.
2493
- hir:: ExprKind :: Path ( hir:: QPath :: TypeRelative ( ..) ) |
2494
-
2495
- hir:: ExprKind :: Call ( ..) |
2496
- hir:: ExprKind :: MethodCall ( ..) |
2497
- hir:: ExprKind :: Struct ( ..) |
2498
- hir:: ExprKind :: Tup ( ..) |
2499
- hir:: ExprKind :: If ( ..) |
2500
- hir:: ExprKind :: Match ( ..) |
2501
- hir:: ExprKind :: Closure ( ..) |
2502
- hir:: ExprKind :: Block ( ..) |
2503
- hir:: ExprKind :: Repeat ( ..) |
2504
- hir:: ExprKind :: Array ( ..) |
2505
- hir:: ExprKind :: Break ( ..) |
2506
- hir:: ExprKind :: Continue ( ..) |
2507
- hir:: ExprKind :: Ret ( ..) |
2508
- hir:: ExprKind :: While ( ..) |
2509
- hir:: ExprKind :: Loop ( ..) |
2510
- hir:: ExprKind :: Assign ( ..) |
2511
- hir:: ExprKind :: InlineAsm ( ..) |
2512
- hir:: ExprKind :: AssignOp ( ..) |
2513
- hir:: ExprKind :: Lit ( _) |
2514
- hir:: ExprKind :: Unary ( ..) |
2515
- hir:: ExprKind :: Box ( ..) |
2516
- hir:: ExprKind :: AddrOf ( ..) |
2517
- hir:: ExprKind :: Binary ( ..) |
2518
- hir:: ExprKind :: Yield ( ..) |
2519
- hir:: ExprKind :: Cast ( ..) => {
2520
- false
2521
- }
2522
- }
2523
- }
2524
-
2525
2472
/// For the overloaded place expressions (`*x`, `x[3]`), the trait
2526
2473
/// returns a type of `&T`, but the actual type we assign to the
2527
2474
/// *expression* is `T`. So this function just peels off the return
@@ -3799,10 +3746,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3799
3746
ty
3800
3747
}
3801
3748
3802
- fn check_expr_kind ( & self ,
3803
- expr : & ' gcx hir:: Expr ,
3804
- expected : Expectation < ' tcx > ,
3805
- needs : Needs ) -> Ty < ' tcx > {
3749
+ fn check_expr_kind (
3750
+ & self ,
3751
+ expr : & ' gcx hir:: Expr ,
3752
+ expected : Expectation < ' tcx > ,
3753
+ needs : Needs
3754
+ ) -> Ty < ' tcx > {
3806
3755
let tcx = self . tcx ;
3807
3756
let id = expr. id ;
3808
3757
match expr. node {
@@ -3899,7 +3848,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3899
3848
let hint = expected. only_has_type ( self ) . map_or ( NoExpectation , |ty| {
3900
3849
match ty. sty {
3901
3850
ty:: Ref ( _, ty, _) | ty:: RawPtr ( ty:: TypeAndMut { ty, .. } ) => {
3902
- if self . is_place_expr ( & oprnd ) {
3851
+ if oprnd . is_place_expr ( ) {
3903
3852
// Places may legitimately have unsized types.
3904
3853
// For example, dereferences of a fat pointer and
3905
3854
// the last field of a struct can be unsized.
@@ -4075,7 +4024,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4075
4024
_ => {
4076
4025
// Only check this if not in an `if` condition, as the
4077
4026
// mistyped comparison help is more appropriate.
4078
- if !self . is_place_expr ( & lhs ) {
4027
+ if !lhs . is_place_expr ( ) {
4079
4028
struct_span_err ! ( self . tcx. sess, expr. span, E0070 ,
4080
4029
"invalid left-hand side expression" )
4081
4030
. span_label ( expr. span , "left-hand of expression not valid" )
@@ -4203,6 +4152,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4203
4152
hir:: ExprKind :: Type ( ref e, ref t) => {
4204
4153
let ty = self . to_ty ( & t) ;
4205
4154
self . check_expr_eq_type ( & e, ty) ;
4155
+ let c_ty = self . infcx . canonicalize_response ( & ty) ;
4156
+ self . tables . borrow_mut ( ) . user_provided_tys_mut ( ) . insert ( t. hir_id , c_ty) ;
4206
4157
ty
4207
4158
}
4208
4159
hir:: ExprKind :: Array ( ref args) => {
0 commit comments