@@ -58,7 +58,7 @@ fn bad_struct_kind_err(sess: &Session, pat: &hir::Pat, path: &hir::Path, lint: b
5858
5959impl < ' a , ' tcx > PatCtxt < ' a , ' tcx , ' tcx > {
6060pub fn check_pat ( & self , pat : & ' tcx hir:: Pat , expected : Ty < ' tcx > ) {
61- let tcx = self . tcx ( ) ;
61+ let tcx = self . tcx ;
6262
6363 debug ! ( "check_pat(pat={:?},expected={:?})" , pat, expected) ;
6464
@@ -126,15 +126,15 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
126126 span_err ! ( tcx. sess, span, E0029 ,
127127 "only char and numeric types are allowed in range patterns\n \
128128 start type: {}\n end type: {}",
129- self . infcx ( ) . ty_to_string( lhs_ty) ,
130- self . infcx ( ) . ty_to_string( rhs_ty)
129+ self . ty_to_string( lhs_ty) ,
130+ self . ty_to_string( rhs_ty)
131131 ) ;
132132 return ;
133133 }
134134
135135 // Check that the types of the end-points can be unified.
136136 let types_unify = require_same_types (
137- self . ccx , Some ( self . infcx ( ) ) , pat. span , rhs_ty, lhs_ty,
137+ self . ccx , Some ( self ) , pat. span , rhs_ty, lhs_ty,
138138 "mismatched types in range" ,
139139 ) ;
140140
@@ -145,7 +145,7 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
145145
146146 // Now that we know the types can be unified we find the unified type and use
147147 // it to type the entire expression.
148- let common_type = self . infcx ( ) . resolve_type_vars_if_possible ( & lhs_ty) ;
148+ let common_type = self . resolve_type_vars_if_possible ( & lhs_ty) ;
149149
150150 self . write_ty ( pat. id , common_type) ;
151151
@@ -181,7 +181,7 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
181181 // ref x | ref const x | ref mut x
182182 // then `x` is assigned a value of type `&M T` where M is the mutability
183183 // and T is the expected type.
184- let region_var = self . infcx ( ) . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
184+ let region_var = self . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
185185 let mt = ty:: TypeAndMut { ty : expected, mutbl : mutbl } ;
186186 let region_ty = tcx. mk_ref ( tcx. mk_region ( region_var) , mt) ;
187187
@@ -227,14 +227,14 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
227227 let self_ty = self . to_ty ( & qself. ty ) ;
228228 let path_res = if let Some ( & d) = tcx. def_map . borrow ( ) . get ( & pat. id ) {
229229 if d. base_def == Def :: Err {
230- self . infcx ( ) . set_tainted_by_errors ( ) ;
230+ self . set_tainted_by_errors ( ) ;
231231 self . write_error ( pat. id ) ;
232232 return ;
233233 }
234234 d
235235 } else if qself. position == 0 {
236236 // This is just a sentinel for finish_resolving_def_to_ty.
237- let sentinel = self . tcx ( ) . map . local_def_id ( ast:: CRATE_NODE_ID ) ;
237+ let sentinel = self . tcx . map . local_def_id ( ast:: CRATE_NODE_ID ) ;
238238 def:: PathResolution {
239239 base_def : Def :: Mod ( sentinel) ,
240240 depth : path. segments . len ( )
@@ -264,8 +264,7 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
264264 }
265265 PatKind :: Tup ( ref elements) => {
266266 let element_tys: Vec < _ > =
267- ( 0 ..elements. len ( ) ) . map ( |_| self . infcx ( ) . next_ty_var ( ) )
268- . collect ( ) ;
267+ ( 0 ..elements. len ( ) ) . map ( |_| self . next_ty_var ( ) ) . collect ( ) ;
269268 let pat_ty = tcx. mk_tup ( element_tys. clone ( ) ) ;
270269 self . write_ty ( pat. id , pat_ty) ;
271270 self . demand_eqtype ( pat. span , expected, pat_ty) ;
@@ -274,7 +273,7 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
274273 }
275274 }
276275 PatKind :: Box ( ref inner) => {
277- let inner_ty = self . infcx ( ) . next_ty_var ( ) ;
276+ let inner_ty = self . next_ty_var ( ) ;
278277 let uniq_ty = tcx. mk_box ( inner_ty) ;
279278
280279 if self . check_dereferencable ( pat. span , expected, & inner) {
@@ -290,7 +289,7 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
290289 }
291290 }
292291 PatKind :: Ref ( ref inner, mutbl) => {
293- let expected = self . infcx ( ) . shallow_resolve ( expected) ;
292+ let expected = self . shallow_resolve ( expected) ;
294293 if self . check_dereferencable ( pat. span , expected, & inner) {
295294 // `demand::subtype` would be good enough, but using
296295 // `eqtype` turns out to be equally general. See (*)
@@ -305,9 +304,9 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
305304 ( expected, mt. ty )
306305 }
307306 _ => {
308- let inner_ty = self . infcx ( ) . next_ty_var ( ) ;
307+ let inner_ty = self . next_ty_var ( ) ;
309308 let mt = ty:: TypeAndMut { ty : inner_ty, mutbl : mutbl } ;
310- let region = self . infcx ( ) . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
309+ let region = self . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
311310 let rptr_ty = tcx. mk_ref ( tcx. mk_region ( region) , mt) ;
312311 self . demand_eqtype ( pat. span , expected, rptr_ty) ;
313312 ( rptr_ty, inner_ty)
@@ -323,7 +322,7 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
323322 }
324323 PatKind :: Vec ( ref before, ref slice, ref after) => {
325324 let expected_ty = self . structurally_resolved_type ( pat. span , expected) ;
326- let inner_ty = self . infcx ( ) . next_ty_var ( ) ;
325+ let inner_ty = self . next_ty_var ( ) ;
327326 let pat_ty = match expected_ty. sty {
328327 ty:: TyArray ( _, size) => tcx. mk_array ( inner_ty, {
329328 let min_len = before. len ( ) + after. len ( ) ;
@@ -333,7 +332,7 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
333332 }
334333 } ) ,
335334 _ => {
336- let region = self . infcx ( ) . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
335+ let region = self . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
337336 tcx. mk_ref ( tcx. mk_region ( region) , ty:: TypeAndMut {
338337 ty : tcx. mk_slice ( inner_ty) ,
339338 mutbl : expected_ty. builtin_deref ( true , ty:: NoPreference ) . map ( |mt| mt. mutbl )
@@ -353,7 +352,7 @@ pub fn check_pat(&self, pat: &'tcx hir::Pat, expected: Ty<'tcx>) {
353352 self . check_pat ( & elt, inner_ty) ;
354353 }
355354 if let Some ( ref slice) = * slice {
356- let region = self . infcx ( ) . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
355+ let region = self . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
357356 let mutbl = expected_ty. builtin_deref ( true , ty:: NoPreference )
358357 . map_or ( hir:: MutImmutable , |mt| mt. mutbl ) ;
359358
@@ -425,7 +424,7 @@ fn check_assoc_item_is_const(&self, def: Def, span: Span) -> bool {
425424 match def {
426425 Def :: AssociatedConst ( ..) => true ,
427426 Def :: Method ( ..) => {
428- span_err ! ( self . tcx( ) . sess, span, E0327 ,
427+ span_err ! ( self . tcx. sess, span, E0327 ,
429428 "associated items in match patterns must be constants" ) ;
430429 false
431430 }
@@ -436,16 +435,16 @@ fn check_assoc_item_is_const(&self, def: Def, span: Span) -> bool {
436435}
437436
438437pub fn check_dereferencable ( & self , span : Span , expected : Ty < ' tcx > , inner : & hir:: Pat ) -> bool {
439- let tcx = self . tcx ( ) ;
438+ let tcx = self . tcx ;
440439 if pat_is_binding ( & tcx. def_map . borrow ( ) , inner) {
441- let expected = self . infcx ( ) . shallow_resolve ( expected) ;
440+ let expected = self . shallow_resolve ( expected) ;
442441 expected. builtin_deref ( true , ty:: NoPreference ) . map_or ( true , |mt| match mt. ty . sty {
443442 ty:: TyTrait ( _) => {
444443 // This is "x = SomeTrait" being reduced from
445444 // "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
446445 span_err ! ( tcx. sess, span, E0033 ,
447446 "type `{}` cannot be dereferenced" ,
448- self . infcx ( ) . ty_to_string( expected) ) ;
447+ self . ty_to_string( expected) ) ;
449448 false
450449 }
451450 _ => true
@@ -463,7 +462,7 @@ pub fn check_match(&self,
463462 arms : & ' tcx [ hir:: Arm ] ,
464463 expected : Expectation < ' tcx > ,
465464 match_src : hir:: MatchSource ) {
466- let tcx = self . tcx ( ) ;
465+ let tcx = self . tcx ;
467466
468467 // Not entirely obvious: if matches may create ref bindings, we
469468 // want to use the *precise* type of the discriminant, *not* some
@@ -482,7 +481,7 @@ pub fn check_match(&self,
482481 // ...but otherwise we want to use any supertype of the
483482 // discriminant. This is sort of a workaround, see note (*) in
484483 // `check_pat` for some details.
485- discrim_ty = self . infcx ( ) . next_ty_var ( ) ;
484+ discrim_ty = self . next_ty_var ( ) ;
486485 self . check_expr_has_type ( discrim, discrim_ty) ;
487486 } ;
488487
@@ -508,14 +507,14 @@ pub fn check_match(&self,
508507 // of execution reach it, we will panic, so bottom is an appropriate
509508 // type in that case)
510509 let expected = expected. adjust_for_branches ( self ) ;
511- let mut result_ty = self . infcx ( ) . next_diverging_ty_var ( ) ;
510+ let mut result_ty = self . next_diverging_ty_var ( ) ;
512511 let coerce_first = match expected {
513512 // We don't coerce to `()` so that if the match expression is a
514513 // statement it's branches can have any consistent type. That allows
515514 // us to give better error messages (pointing to a usually better
516515 // arm for inconsistent arms or to the whole match when a `()` type
517516 // is required).
518- Expectation :: ExpectHasType ( ety) if ety != self . tcx ( ) . mk_nil ( ) => {
517+ Expectation :: ExpectHasType ( ety) if ety != self . tcx . mk_nil ( ) => {
519518 ety
520519 }
521520 _ => result_ty
@@ -547,7 +546,7 @@ pub fn check_match(&self,
547546 } ;
548547
549548 let result = if is_if_let_fallback {
550- self . infcx ( ) . eq_types ( true , origin, arm_ty, result_ty)
549+ self . eq_types ( true , origin, arm_ty, result_ty)
551550 . map ( |InferOk { obligations, .. } | {
552551 // FIXME(#32730) propagate obligations
553552 assert ! ( obligations. is_empty( ) ) ;
@@ -569,8 +568,8 @@ pub fn check_match(&self,
569568 } else {
570569 ( result_ty, arm_ty)
571570 } ;
572- self . infcx ( ) . report_mismatched_types ( origin, expected, found, e) ;
573- self . tcx ( ) . types . err
571+ self . report_mismatched_types ( origin, expected, found, e) ;
572+ self . tcx . types . err
574573 }
575574 } ;
576575 }
@@ -583,7 +582,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx, 'tcx> {
583582pub fn check_pat_struct ( & self , pat : & ' tcx hir:: Pat ,
584583 path : & hir:: Path , fields : & ' tcx [ Spanned < hir:: FieldPat > ] ,
585584 etc : bool , expected : Ty < ' tcx > ) {
586- let tcx = self . tcx ( ) ;
585+ let tcx = self . tcx ;
587586
588587 let def = tcx. def_map . borrow ( ) . get ( & pat. id ) . unwrap ( ) . full_def ( ) ;
589588 let variant = match self . def_struct_variant ( def, path. span ) {
@@ -621,12 +620,12 @@ fn check_pat_enum(&self,
621620 is_tuple_struct_pat : bool )
622621{
623622 // Typecheck the path.
624- let tcx = self . tcx ( ) ;
623+ let tcx = self . tcx ;
625624
626625 let path_res = match tcx. def_map . borrow ( ) . get ( & pat. id ) {
627626 Some ( & path_res) if path_res. base_def != Def :: Err => path_res,
628627 _ => {
629- self . infcx ( ) . set_tainted_by_errors ( ) ;
628+ self . set_tainted_by_errors ( ) ;
630629 self . write_error ( pat. id ) ;
631630
632631 if let Some ( subpats) = subpats {
@@ -767,7 +766,7 @@ pub fn check_struct_pat_fields(&self,
767766 variant : ty:: VariantDef < ' tcx > ,
768767 substs : & Substs < ' tcx > ,
769768 etc : bool ) {
770- let tcx = self . tcx ( ) ;
769+ let tcx = self . tcx ;
771770
772771 // Index the struct fields' types.
773772 let field_map = variant. fields
0 commit comments