@@ -2447,59 +2447,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2447
2447
}
2448
2448
}
2449
2449
2450
- fn is_place_expr ( & self , expr : & hir:: Expr ) -> bool {
2451
- match expr. node {
2452
- hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( _, ref path) ) => {
2453
- match path. def {
2454
- Def :: Local ( ..) | Def :: Upvar ( ..) | Def :: Static ( ..) | Def :: Err => true ,
2455
- _ => false ,
2456
- }
2457
- }
2458
-
2459
- hir:: ExprKind :: Type ( ref e, _) => {
2460
- self . is_place_expr ( e)
2461
- }
2462
-
2463
- hir:: ExprKind :: Unary ( hir:: UnDeref , _) |
2464
- hir:: ExprKind :: Field ( ..) |
2465
- hir:: ExprKind :: Index ( ..) => {
2466
- true
2467
- }
2468
-
2469
- // Partially qualified paths in expressions can only legally
2470
- // refer to associated items which are always rvalues.
2471
- hir:: ExprKind :: Path ( hir:: QPath :: TypeRelative ( ..) ) |
2472
-
2473
- hir:: ExprKind :: Call ( ..) |
2474
- hir:: ExprKind :: MethodCall ( ..) |
2475
- hir:: ExprKind :: Struct ( ..) |
2476
- hir:: ExprKind :: Tup ( ..) |
2477
- hir:: ExprKind :: If ( ..) |
2478
- hir:: ExprKind :: Match ( ..) |
2479
- hir:: ExprKind :: Closure ( ..) |
2480
- hir:: ExprKind :: Block ( ..) |
2481
- hir:: ExprKind :: Repeat ( ..) |
2482
- hir:: ExprKind :: Array ( ..) |
2483
- hir:: ExprKind :: Break ( ..) |
2484
- hir:: ExprKind :: Continue ( ..) |
2485
- hir:: ExprKind :: Ret ( ..) |
2486
- hir:: ExprKind :: While ( ..) |
2487
- hir:: ExprKind :: Loop ( ..) |
2488
- hir:: ExprKind :: Assign ( ..) |
2489
- hir:: ExprKind :: InlineAsm ( ..) |
2490
- hir:: ExprKind :: AssignOp ( ..) |
2491
- hir:: ExprKind :: Lit ( _) |
2492
- hir:: ExprKind :: Unary ( ..) |
2493
- hir:: ExprKind :: Box ( ..) |
2494
- hir:: ExprKind :: AddrOf ( ..) |
2495
- hir:: ExprKind :: Binary ( ..) |
2496
- hir:: ExprKind :: Yield ( ..) |
2497
- hir:: ExprKind :: Cast ( ..) => {
2498
- false
2499
- }
2500
- }
2501
- }
2502
-
2503
2450
/// For the overloaded place expressions (`*x`, `x[3]`), the trait
2504
2451
/// returns a type of `&T`, but the actual type we assign to the
2505
2452
/// *expression* is `T`. So this function just peels off the return
@@ -3762,10 +3709,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3762
3709
ty
3763
3710
}
3764
3711
3765
- fn check_expr_kind ( & self ,
3766
- expr : & ' gcx hir:: Expr ,
3767
- expected : Expectation < ' tcx > ,
3768
- needs : Needs ) -> Ty < ' tcx > {
3712
+ fn check_expr_kind (
3713
+ & self ,
3714
+ expr : & ' gcx hir:: Expr ,
3715
+ expected : Expectation < ' tcx > ,
3716
+ needs : Needs
3717
+ ) -> Ty < ' tcx > {
3769
3718
let tcx = self . tcx ;
3770
3719
let id = expr. id ;
3771
3720
match expr. node {
@@ -3862,7 +3811,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3862
3811
let hint = expected. only_has_type ( self ) . map_or ( NoExpectation , |ty| {
3863
3812
match ty. sty {
3864
3813
ty:: Ref ( _, ty, _) | ty:: RawPtr ( ty:: TypeAndMut { ty, .. } ) => {
3865
- if self . is_place_expr ( & oprnd ) {
3814
+ if oprnd . is_place_expr ( ) {
3866
3815
// Places may legitimately have unsized types.
3867
3816
// For example, dereferences of a fat pointer and
3868
3817
// the last field of a struct can be unsized.
@@ -4041,7 +3990,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4041
3990
_ => {
4042
3991
// Only check this if not in an `if` condition, as the
4043
3992
// mistyped comparison help is more appropriate.
4044
- if !self . is_place_expr ( & lhs ) {
3993
+ if !lhs . is_place_expr ( ) {
4045
3994
struct_span_err ! ( self . tcx. sess, expr. span, E0070 ,
4046
3995
"invalid left-hand side expression" )
4047
3996
. span_label ( expr. span , "left-hand of expression not valid" )
0 commit comments