1
- use crate :: { FnCtxt , LocalTy } ;
1
+ use crate :: FnCtxt ;
2
2
use rustc_hir as hir;
3
3
use rustc_hir:: intravisit:: { self , Visitor } ;
4
4
use rustc_hir:: PatKind ;
@@ -48,31 +48,28 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
48
48
Self { fcx, outermost_fn_param_pat : None }
49
49
}
50
50
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 > {
52
52
match ty_opt {
53
53
None => {
54
54
// Infer the variable's type.
55
55
let var_ty = self . fcx . next_ty_var ( TypeVariableOrigin {
56
56
kind : TypeVariableOriginKind :: TypeInference ,
57
57
span,
58
58
} ) ;
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) ;
63
60
var_ty
64
61
}
65
62
Some ( typ) => {
66
63
// Take type that the user specified.
67
64
self . fcx . locals . borrow_mut ( ) . insert ( nid, typ) ;
68
- typ. revealed_ty
65
+ typ
69
66
}
70
67
}
71
68
}
72
69
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.
76
73
fn declare ( & mut self , decl : Declaration < ' tcx > ) {
77
74
let local_ty = match decl. ty {
78
75
Some ( ref ty) => {
@@ -87,7 +84,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
87
84
. user_provided_types_mut ( )
88
85
. insert ( ty. hir_id , c_ty) ;
89
86
90
- Some ( LocalTy { decl_ty : o_ty. normalized , revealed_ty : o_ty . normalized } )
87
+ Some ( o_ty. normalized )
91
88
}
92
89
None => None ,
93
90
} ;
@@ -96,7 +93,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
96
93
debug ! (
97
94
"local variable {:?} is assigned type {}" ,
98
95
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( ) )
100
97
) ;
101
98
}
102
99
}
@@ -151,7 +148,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
151
148
debug ! (
152
149
"pattern binding {} is assigned to {} with type {:?}" ,
153
150
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( ) ) ,
155
152
var_ty
156
153
) ;
157
154
}
0 commit comments