1- use crate :: { FnCtxt , LocalTy } ;
1+ use crate :: FnCtxt ;
22use rustc_hir as hir;
33use rustc_hir:: intravisit:: { self , Visitor } ;
44use rustc_hir:: PatKind ;
@@ -48,31 +48,28 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
4848 Self { fcx, outermost_fn_param_pat : None }
4949 }
5050
51- fn assign ( & mut self , span : Span , nid : hir:: HirId , ty_opt : Option < LocalTy < ' tcx > > ) -> Ty < ' tcx > {
51+ fn assign ( & mut self , span : Span , nid : hir:: HirId , ty_opt : Option < Ty < ' tcx > > ) -> Ty < ' tcx > {
5252 match ty_opt {
5353 None => {
5454 // Infer the variable's type.
5555 let var_ty = self . fcx . next_ty_var ( TypeVariableOrigin {
5656 kind : TypeVariableOriginKind :: TypeInference ,
5757 span,
5858 } ) ;
59- self . fcx
60- . locals
61- . borrow_mut ( )
62- . insert ( nid, LocalTy { decl_ty : var_ty, revealed_ty : var_ty } ) ;
59+ self . fcx . locals . borrow_mut ( ) . insert ( nid, var_ty) ;
6360 var_ty
6461 }
6562 Some ( typ) => {
6663 // Take type that the user specified.
6764 self . fcx . locals . borrow_mut ( ) . insert ( nid, typ) ;
68- typ. revealed_ty
65+ typ
6966 }
7067 }
7168 }
7269
73- /// Allocates a [LocalTy] for a declaration, which may have a type annotation. If it does have
74- /// a type annotation, then the LocalTy stored will be the resolved type. This may be found
75- /// again during type checking by querying [FnCtxt::local_ty] for the same hir_id.
70+ /// Allocates a type for a declaration, which may have a type annotation. If it does have
71+ /// a type annotation, then the [`Ty`] stored will be the resolved type. This may be found
72+ /// again during type checking by querying [` FnCtxt::local_ty` ] for the same hir_id.
7673 fn declare ( & mut self , decl : Declaration < ' tcx > ) {
7774 let local_ty = match decl. ty {
7875 Some ( ref ty) => {
@@ -87,7 +84,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
8784 . user_provided_types_mut ( )
8885 . insert ( ty. hir_id , c_ty) ;
8986
90- Some ( LocalTy { decl_ty : o_ty. normalized , revealed_ty : o_ty . normalized } )
87+ Some ( o_ty. normalized )
9188 }
9289 None => None ,
9390 } ;
@@ -96,7 +93,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
9693 debug ! (
9794 "local variable {:?} is assigned type {}" ,
9895 decl. pat,
99- self . fcx. ty_to_string( self . fcx. locals. borrow( ) . get( & decl. hir_id) . unwrap( ) . decl_ty )
96+ self . fcx. ty_to_string( * self . fcx. locals. borrow( ) . get( & decl. hir_id) . unwrap( ) )
10097 ) ;
10198 }
10299}
@@ -151,7 +148,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
151148 debug ! (
152149 "pattern binding {} is assigned to {} with type {:?}" ,
153150 ident,
154- self . fcx. ty_to_string( self . fcx. locals. borrow( ) . get( & p. hir_id) . unwrap( ) . decl_ty ) ,
151+ self . fcx. ty_to_string( * self . fcx. locals. borrow( ) . get( & p. hir_id) . unwrap( ) ) ,
155152 var_ty
156153 ) ;
157154 }
0 commit comments