@@ -1933,7 +1933,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1933
1933
}
1934
1934
1935
1935
pub fn to_ty ( & self , ast_t : & ast:: Ty ) -> Ty < ' tcx > {
1936
- let t = ast_ty_to_ty ( self , self . infcx ( ) , ast_t) ;
1936
+ let t = ast_ty_to_ty ( self , self , ast_t) ;
1937
1937
1938
1938
let mut bounds_checker = wf:: BoundsChecker :: new ( self ,
1939
1939
ast_t. span ,
@@ -2123,18 +2123,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2123
2123
}
2124
2124
}
2125
2125
2126
- // impl<'a, 'tcx> RegionScope for infer::InferCtxt <'a, 'tcx> {
2127
- // fn default_region_bound(&self, span: Span) -> Option<ty::Region> {
2128
- // Some(self.next_region_var(infer::MiscVariable(span)))
2129
- // }
2130
- //
2131
- // fn anon_regions(&self, span: Span, count: uint)
2132
- // -> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>> {
2133
- // Ok(Vec::from_fn(count, |_| {
2134
- // self.next_region_var(infer::MiscVariable(span))
2135
- // }))
2136
- // }
2137
- // }
2126
+ impl < ' a , ' tcx > RegionScope for FnCtxt < ' a , ' tcx > {
2127
+ fn default_region_bound ( & self , span : Span ) -> Option < ty:: Region > {
2128
+ Some ( self . infcx ( ) . next_region_var ( infer:: MiscVariable ( span) ) )
2129
+ }
2130
+
2131
+ fn anon_regions ( & self , span : Span , count : uint )
2132
+ -> Result < Vec < ty:: Region > , Option < Vec < ( String , uint ) > > > {
2133
+ Ok ( Vec :: from_fn ( count, |_| {
2134
+ self . infcx ( ) . next_region_var ( infer:: MiscVariable ( span) )
2135
+ } ) )
2136
+ }
2137
+ }
2138
2138
2139
2139
#[ deriving( Copy , Show , PartialEq , Eq ) ]
2140
2140
pub enum LvaluePreference {
@@ -2347,58 +2347,6 @@ fn autoderef_for_index<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>,
2347
2347
}
2348
2348
}
2349
2349
2350
- /// Autoderefs `base_expr`, looking for a `Slice` impl. If it finds one, installs the relevant
2351
- /// method info and returns the result type (else None).
2352
- fn try_overloaded_slice < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
2353
- method_call : MethodCall ,
2354
- expr : & ast:: Expr ,
2355
- base_expr : & ast:: Expr ,
2356
- base_ty : Ty < ' tcx > ,
2357
- start_expr : & Option < P < ast:: Expr > > ,
2358
- end_expr : & Option < P < ast:: Expr > > ,
2359
- mutbl : ast:: Mutability )
2360
- -> Option < Ty < ' tcx > > // return type is result of slice
2361
- {
2362
- let lvalue_pref = match mutbl {
2363
- ast:: MutMutable => PreferMutLvalue ,
2364
- ast:: MutImmutable => NoPreference
2365
- } ;
2366
-
2367
- let opt_method_ty =
2368
- autoderef_for_index ( fcx, base_expr, base_ty, lvalue_pref, |adjusted_ty, autoderefref| {
2369
- try_overloaded_slice_step ( fcx, method_call, expr, base_expr,
2370
- adjusted_ty, autoderefref, mutbl,
2371
- start_expr, end_expr)
2372
- } ) ;
2373
-
2374
- // Regardless of whether the lookup succeeds, check the method arguments
2375
- // so that we have *some* type for each argument.
2376
- let method_ty_or_err = opt_method_ty. unwrap_or ( fcx. tcx ( ) . types . err ) ;
2377
-
2378
- let mut args = vec ! [ ] ;
2379
- start_expr. as_ref ( ) . map ( |x| args. push ( x) ) ;
2380
- end_expr. as_ref ( ) . map ( |x| args. push ( x) ) ;
2381
-
2382
- check_method_argument_types ( fcx,
2383
- expr. span ,
2384
- method_ty_or_err,
2385
- expr,
2386
- args. as_slice ( ) ,
2387
- AutorefArgs :: Yes ,
2388
- DontTupleArguments ) ;
2389
-
2390
- opt_method_ty. map ( |method_ty| {
2391
- let result_ty = ty:: ty_fn_ret ( method_ty) ;
2392
- match result_ty {
2393
- ty:: FnConverging ( result_ty) => result_ty,
2394
- ty:: FnDiverging => {
2395
- fcx. tcx ( ) . sess . span_bug ( expr. span ,
2396
- "slice trait does not define a `!` return" )
2397
- }
2398
- }
2399
- } )
2400
- }
2401
-
2402
2350
/// Checks for a `Slice` (or `SliceMut`) impl at the relevant level of autoderef. If it finds one,
2403
2351
/// installs method info and returns type of method (else None).
2404
2352
fn try_overloaded_slice_step < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
@@ -4327,7 +4275,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4327
4275
let actual_structure_type = fcx. expr_ty ( & * expr) ;
4328
4276
if !ty:: type_is_error ( actual_structure_type) {
4329
4277
let type_and_substs = astconv:: ast_path_to_ty_relaxed ( fcx,
4330
- fcx. infcx ( ) ,
4278
+ fcx,
4331
4279
struct_id,
4332
4280
path) ;
4333
4281
match fcx. mk_subty ( false ,
@@ -4410,8 +4358,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4410
4358
} ,
4411
4359
base_t,
4412
4360
None ) ;
4413
- fcx. write_ty ( idx. id , ty :: mk_err ( ) ) ;
4414
- fcx. write_ty ( id, ty :: mk_err ( ) )
4361
+ fcx. write_ty ( idx. id , fcx . tcx ( ) . types . err ) ;
4362
+ fcx. write_ty ( id, fcx . tcx ( ) . types . err ) ;
4415
4363
}
4416
4364
}
4417
4365
}
@@ -4440,7 +4388,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4440
4388
fcx. write_ty ( id, element_ty) ;
4441
4389
}
4442
4390
_ => {
4443
- check_expr_has_type ( fcx, & * * idx, ty :: mk_err ( ) ) ;
4391
+ check_expr_has_type ( fcx, & * * idx, fcx . tcx ( ) . types . err ) ;
4444
4392
fcx. type_error_message (
4445
4393
expr. span ,
4446
4394
|actual| {
@@ -4449,7 +4397,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4449
4397
} ,
4450
4398
base_t,
4451
4399
None ) ;
4452
- fcx. write_ty ( id, ty :: mk_err ( ) )
4400
+ fcx. write_ty ( id, fcx . tcx ( ) . types . err ) ;
4453
4401
}
4454
4402
}
4455
4403
}
@@ -4468,19 +4416,21 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4468
4416
} ) ;
4469
4417
4470
4418
let idx_type = match ( t_start, t_end) {
4471
- ( Some ( ty) , None ) | ( None , Some ( ty) ) => Some ( ty) ,
4472
- ( Some ( t_start) , Some ( t_end) )
4473
- if ty:: type_is_error ( t_start) || ty:: type_is_error ( t_end) => {
4474
- Some ( ty:: mk_err ( ) )
4475
- }
4476
- ( Some ( t_start) , Some ( t_end) ) => {
4477
- Some ( infer:: common_supertype ( fcx. infcx ( ) ,
4478
- infer:: RangeExpression ( expr. span ) ,
4479
- true ,
4480
- t_start,
4481
- t_end) )
4482
- }
4483
- _ => None
4419
+ ( Some ( ty) , None ) | ( None , Some ( ty) ) => {
4420
+ Some ( ty)
4421
+ }
4422
+ ( Some ( t_start) , Some ( t_end) ) if ( ty:: type_is_error ( t_start) ||
4423
+ ty:: type_is_error ( t_end) ) => {
4424
+ Some ( fcx. tcx ( ) . types . err )
4425
+ }
4426
+ ( Some ( t_start) , Some ( t_end) ) => {
4427
+ Some ( infer:: common_supertype ( fcx. infcx ( ) ,
4428
+ infer:: RangeExpression ( expr. span ) ,
4429
+ true ,
4430
+ t_start,
4431
+ t_end) )
4432
+ }
4433
+ _ => None
4484
4434
} ;
4485
4435
4486
4436
// Note that we don't check the type of start/end satisfy any
@@ -4489,7 +4439,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4489
4439
4490
4440
let range_type = match idx_type {
4491
4441
Some ( idx_type) if ty:: type_is_error ( idx_type) => {
4492
- ty :: mk_err ( )
4442
+ fcx . tcx ( ) . types . err
4493
4443
}
4494
4444
Some ( idx_type) => {
4495
4445
// Find the did from the appropriate lang item.
@@ -4515,7 +4465,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4515
4465
ty:: mk_struct ( tcx, did, tcx. mk_substs ( substs) )
4516
4466
} else {
4517
4467
tcx. sess . span_err ( expr. span , "No lang item for range syntax" ) ;
4518
- ty :: mk_err ( )
4468
+ fcx . tcx ( ) . types . err
4519
4469
}
4520
4470
}
4521
4471
None => {
@@ -4525,7 +4475,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
4525
4475
ty:: mk_struct ( tcx, did, tcx. mk_substs ( substs) )
4526
4476
} else {
4527
4477
tcx. sess . span_err ( expr. span , "No lang item for range syntax" ) ;
4528
- ty :: mk_err ( )
4478
+ fcx . tcx ( ) . types . err
4529
4479
}
4530
4480
}
4531
4481
} ;
0 commit comments