@@ -2469,59 +2469,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
24692469 }
24702470 }
24712471
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-
25252472 /// For the overloaded place expressions (`*x`, `x[3]`), the trait
25262473 /// returns a type of `&T`, but the actual type we assign to the
25272474 /// *expression* is `T`. So this function just peels off the return
@@ -3799,10 +3746,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
37993746 ty
38003747 }
38013748
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 > {
38063755 let tcx = self . tcx ;
38073756 let id = expr. id ;
38083757 match expr. node {
@@ -3899,7 +3848,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
38993848 let hint = expected. only_has_type ( self ) . map_or ( NoExpectation , |ty| {
39003849 match ty. sty {
39013850 ty:: Ref ( _, ty, _) | ty:: RawPtr ( ty:: TypeAndMut { ty, .. } ) => {
3902- if self . is_place_expr ( & oprnd ) {
3851+ if oprnd . is_place_expr ( ) {
39033852 // Places may legitimately have unsized types.
39043853 // For example, dereferences of a fat pointer and
39053854 // the last field of a struct can be unsized.
@@ -4075,7 +4024,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
40754024 _ => {
40764025 // Only check this if not in an `if` condition, as the
40774026 // mistyped comparison help is more appropriate.
4078- if !self . is_place_expr ( & lhs ) {
4027+ if !lhs . is_place_expr ( ) {
40794028 struct_span_err ! ( self . tcx. sess, expr. span, E0070 ,
40804029 "invalid left-hand side expression" )
40814030 . span_label ( expr. span , "left-hand of expression not valid" )
@@ -4203,6 +4152,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
42034152 hir:: ExprKind :: Type ( ref e, ref t) => {
42044153 let ty = self . to_ty ( & t) ;
42054154 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) ;
42064157 ty
42074158 }
42084159 hir:: ExprKind :: Array ( ref args) => {
0 commit comments