@@ -2564,71 +2564,74 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
25642564 let tcx = fcx. ccx. tcx;
25652565 let id = expr. id;
25662566 match expr. node {
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 ;
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+ }
25822598 }
2583- else if ty:: type_is_bot( arg_t) {
2584- 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+ }
25852620 }
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- }
2598- }
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 ,
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" ) ,
26052631 } ;
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- }
2620- }
2621- ast:: ExprLit ( _) => {
2622- tcx. sess. span_err( expr. span,
2623- "`~\" string\" ` has been removed; use `\" string\" .to_owned()` \
2624- instead") ;
2625- ty:: mk_err ( )
2626- }
2627- _ => tcx. sess. span_bug( expr. span, "vstore modifier on non-sequence" ) ,
2628- } ;
2629- fcx. write_ty( ev. id, typ) ;
2630- fcx. write_ty( id, typ) ;
2631- }
2632+ fcx. write_ty( ev. id, typ) ;
2633+ fcx. write_ty( id, typ) ;
2634+ }
26322635
26332636 ast:: ExprBox ( place, subexpr) => {
26342637 check_expr( fcx, place) ;
0 commit comments