@@ -2564,70 +2564,74 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
2564
2564
let tcx = fcx. ccx. tcx;
2565
2565
let id = expr. id;
2566
2566
match expr. node {
2567
- ast : : ExprVstore ( ev, vst) => {
2568
- let typ = match ev. node {
2569
- ast : : ExprLit ( lit) if ast_util:: lit_is_str( lit) => {
2570
- ast_expr_vstore_to_ty( fcx, ev, vst, || ty:: mt { ty : ty:: mk_str( tcx) ,
2571
- mutbl : ast:: MutImmutable } )
2572
- }
2573
- ast:: ExprVec ( ref args) => {
2574
- let mutability = match vst {
2575
- ast : : ExprVstoreMutSlice => ast:: MutMutable ,
2576
- _ => ast : : MutImmutable ,
2577
- } ;
2578
- let mut any_error = false ;
2579
- let mut any_bot = false ;
2580
- let t: ty:: t = fcx. infcx ( ) . next_ty_var( ) ;
2581
- for e in args. iter( ) {
2582
- check_expr_has_type ( fcx , * e , t ) ;
2583
- let arg_t = fcx. expr_ty( * e) ;
2584
- if ty:: type_is_error ( arg_t ) {
2585
- any_error = true ;
2567
+ ast : : ExprVstore ( ev, vst) => {
2568
+ let typ = match ev. node {
2569
+ ast : : ExprVec ( ref args) => {
2570
+ let mutability = match vst {
2571
+ ast : : ExprVstoreMutSlice => ast:: MutMutable ,
2572
+ _ => ast : : MutImmutable ,
2573
+ } ;
2574
+ let mut any_error = false ;
2575
+ let mut any_bot = false ;
2576
+ let t: ty:: t = fcx. infcx( ) . next_ty_var( ) ;
2577
+ for e in args. iter( ) {
2578
+ check_expr_has_type( fcx, * e, t) ;
2579
+ let arg_t = fcx. expr_ty( * e) ;
2580
+ if ty:: type_is_error( arg_t) {
2581
+ any_error = true ;
2582
+ }
2583
+ else if ty:: type_is_bot( arg_t) {
2584
+ any_bot = true ;
2585
+ }
2586
+ }
2587
+ if any_error {
2588
+ ty : : mk_err( )
2589
+ } else if any_bot {
2590
+ ty : : mk_bot( )
2591
+ } else {
2592
+ ast_expr_vstore_to_ty( fcx, ev, vst, ||
2593
+ ty:: mt { ty : ty:: mk_vec( tcx,
2594
+ ty:: mt { ty : t, mutbl : mutability} ,
2595
+ None ) ,
2596
+ mutbl : mutability } )
2597
+ }
2586
2598
}
2587
- else if ty:: type_is_bot ( arg_t ) {
2588
- any_bot = true ;
2599
+ ast:: ExprRepeat ( element, count_expr) => {
2600
+ check_expr_with_hint( fcx, count_expr, ty:: mk_uint( ) ) ;
2601
+ let _ = ty:: eval_repeat_count ( fcx , count_expr ) ;
2602
+ let mutability = match vst {
2603
+ ast : : ExprVstoreMutSlice => ast:: MutMutable ,
2604
+ _ => ast : : MutImmutable ,
2605
+ } ;
2606
+ let t = fcx. infcx( ) . next_ty_var( ) ;
2607
+ check_expr_has_type( fcx, element, t) ;
2608
+ let arg_t = fcx. expr_ty( element) ;
2609
+ if ty:: type_is_error ( arg_t ) {
2610
+ ty:: mk_err ( )
2611
+ } else if ty:: type_is_bot ( arg_t ) {
2612
+ ty:: mk_bot ( )
2613
+ } else {
2614
+ ast_expr_vstore_to_ty( fcx, ev, vst, ||
2615
+ ty:: mt { ty : ty:: mk_vec( tcx,
2616
+ ty:: mt { ty : t, mutbl : mutability} ,
2617
+ None ) ,
2618
+ mutbl : mutability} )
2619
+ }
2589
2620
}
2590
- }
2591
- if any_error {
2592
- ty : : mk_err( )
2593
- } else if any_bot {
2594
- ty : : mk_bot( )
2595
- } else {
2596
- ast_expr_vstore_to_ty( fcx, ev, vst, ||
2597
- ty:: mt { ty : ty:: mk_vec( tcx,
2598
- ty:: mt { ty : t, mutbl : mutability} ,
2599
- None ) ,
2600
- mutbl : mutability } )
2601
- }
2602
- }
2603
- ast:: ExprRepeat ( element , count_expr ) => {
2604
- check_expr_with_hint( fcx, count_expr, ty:: mk_uint( ) ) ;
2605
- let _ = ty:: eval_repeat_count ( fcx , count_expr ) ;
2606
- let mutability = match vst {
2607
- ast : : ExprVstoreMutSlice => ast:: MutMutable ,
2608
- _ => ast : : MutImmutable ,
2621
+ ast:: ExprLit ( _) => {
2622
+ let error = if vst == ast:: ExprVstoreSlice {
2623
+ "`&\" string\" ` has been removed; use `\" string\" ` instead"
2624
+ } else {
2625
+ "`~\" string\" ` has been removed; use `\" string\" .to_owned()` instead"
2626
+ } ;
2627
+ tcx. sess. span_err( expr. span, error) ;
2628
+ ty:: mk_err ( )
2629
+ }
2630
+ _ => tcx. sess. span_bug( expr. span, "vstore modifier on non-sequence" ) ,
2609
2631
} ;
2610
- let t = fcx. infcx( ) . next_ty_var( ) ;
2611
- check_expr_has_type( fcx, element, t) ;
2612
- let arg_t = fcx. expr_ty( element) ;
2613
- if ty:: type_is_error ( arg_t ) {
2614
- ty:: mk_err ( )
2615
- } else if ty:: type_is_bot ( arg_t ) {
2616
- ty:: mk_bot ( )
2617
- } else {
2618
- ast_expr_vstore_to_ty( fcx, ev, vst, ||
2619
- ty:: mt { ty : ty:: mk_vec( tcx,
2620
- ty:: mt { ty : t, mutbl : mutability} ,
2621
- None ) ,
2622
- mutbl : mutability} )
2623
- }
2624
- }
2625
- _ =>
2626
- tcx. sess. span_bug( expr. span, "vstore modifier on non-sequence" )
2627
- } ;
2628
- fcx. write_ty( ev. id, typ) ;
2629
- fcx. write_ty( id, typ) ;
2630
- }
2632
+ fcx. write_ty( ev. id, typ) ;
2633
+ fcx. write_ty( id, typ) ;
2634
+ }
2631
2635
2632
2636
ast:: ExprBox ( place, subexpr) => {
2633
2637
check_expr( fcx, place) ;
0 commit comments