@@ -4183,9 +4183,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4183
4183
// A slice, rather than an index. Special cased for now (KILLME).
4184
4184
let base_t = structurally_resolved_type ( fcx, expr. span , base_t) ;
4185
4185
4186
- if lvalue_pref == PreferMutLvalue {
4187
- println ! ( "mutable lvalue_pref" ) ;
4188
- }
4189
4186
let result =
4190
4187
autoderef_for_index ( fcx, & * * base, base_t, lvalue_pref, |adj_ty, adj| {
4191
4188
try_overloaded_slice_step ( fcx,
@@ -4299,42 +4296,49 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4299
4296
// bounds because right the range structs do not have any. If we add
4300
4297
// some bounds, then we'll need to check `t_start` against them here.
4301
4298
4302
- let range_type = if idx_type == Some ( ty:: mk_err ( ) ) {
4303
- ty:: mk_err ( )
4304
- } else if idx_type. is_none ( ) {
4305
- // Neither start nor end => FullRange
4306
- if let Some ( did) = tcx. lang_items . full_range_struct ( ) {
4307
- let substs = Substs :: new_type ( vec ! [ ] , vec ! [ ] ) ;
4308
- ty:: mk_struct ( tcx, did, substs)
4309
- } else {
4299
+ let range_type = match idx_type {
4300
+ Some ( idx_type) if ty:: type_is_error ( idx_type) => {
4310
4301
ty:: mk_err ( )
4311
4302
}
4312
- } else {
4313
- // Find the did from the appropriate lang item.
4314
- let did = match ( start, end) {
4315
- ( & Some ( _) , & Some ( _) ) => tcx. lang_items . range_struct ( ) ,
4316
- ( & Some ( _) , & None ) => tcx. lang_items . range_from_struct ( ) ,
4317
- ( & None , & Some ( _) ) => tcx. lang_items . range_to_struct ( ) ,
4318
- ( & None , & None ) => {
4319
- tcx. sess . span_bug ( expr. span , "full range should be dealt with above" )
4320
- }
4321
- } ;
4303
+ Some ( idx_type ) => {
4304
+ // Find the did from the appropriate lang item.
4305
+ let did = match ( start, end) {
4306
+ ( & Some ( _) , & Some ( _) ) => tcx. lang_items . range_struct ( ) ,
4307
+ ( & Some ( _) , & None ) => tcx. lang_items . range_from_struct ( ) ,
4308
+ ( & None , & Some ( _) ) => tcx. lang_items . range_to_struct ( ) ,
4309
+ ( & None , & None ) => {
4310
+ tcx. sess . span_bug ( expr. span , "full range should be dealt with above" )
4311
+ }
4312
+ } ;
4322
4313
4323
- if let Some ( did) = did {
4324
- let polytype = ty:: lookup_item_type ( tcx, did) ;
4325
- let substs = Substs :: new_type ( vec ! [ idx_type. unwrap( ) ] , vec ! [ ] ) ;
4326
- let bounds = polytype. generics . to_bounds ( tcx, & substs) ;
4327
- fcx. add_obligations_for_parameters (
4328
- traits:: ObligationCause :: new ( expr. span ,
4329
- fcx. body_id ,
4330
- traits:: ItemObligation ( did) ) ,
4331
- & bounds) ;
4332
-
4333
- ty:: mk_struct ( tcx, did, tcx. mk_substs ( substs) )
4334
- } else {
4335
- ty:: mk_err ( )
4314
+ if let Some ( did) = did {
4315
+ let polytype = ty:: lookup_item_type ( tcx, did) ;
4316
+ let substs = Substs :: new_type ( vec ! [ idx_type] , vec ! [ ] ) ;
4317
+ let bounds = polytype. generics . to_bounds ( tcx, & substs) ;
4318
+ fcx. add_obligations_for_parameters (
4319
+ traits:: ObligationCause :: new ( expr. span ,
4320
+ fcx. body_id ,
4321
+ traits:: ItemObligation ( did) ) ,
4322
+ & bounds) ;
4323
+
4324
+ ty:: mk_struct ( tcx, did, tcx. mk_substs ( substs) )
4325
+ } else {
4326
+ tcx. sess . span_err ( expr. span , "No lang item for range syntax" ) ;
4327
+ ty:: mk_err ( )
4328
+ }
4329
+ }
4330
+ None => {
4331
+ // Neither start nor end => FullRange
4332
+ if let Some ( did) = tcx. lang_items . full_range_struct ( ) {
4333
+ let substs = Substs :: new_type ( vec ! [ ] , vec ! [ ] ) ;
4334
+ ty:: mk_struct ( tcx, did, tcx. mk_substs ( substs) )
4335
+ } else {
4336
+ tcx. sess . span_err ( expr. span , "No lang item for range syntax" ) ;
4337
+ ty:: mk_err ( )
4338
+ }
4336
4339
}
4337
4340
} ;
4341
+
4338
4342
fcx. write_ty ( id, range_type) ;
4339
4343
}
4340
4344
0 commit comments