@@ -82,8 +82,33 @@ type fn_ctxt =
82
82
locals : hashmap < ast:: node_id , int > ,
83
83
next_var_id : @mut int ,
84
84
next_region_var_id : @mut int ,
85
+
86
+ // While type checking a function, the intermediate types for the
87
+ // expressions, blocks, and so forth contained within the function are
88
+ // stored in these tables. These types may contain unresolved type
89
+ // variables. After type checking is complete, the functions in the
90
+ // writeback module are used to take the types from this table, resolve
91
+ // them, and then write them into their permanent home in the type
92
+ // context `ccx.tcx`.
93
+ //
94
+ // This means that during inferencing you should use `fcx.write_ty()`
95
+ // and `fcx.expr_ty()` / `fcx.node_ty()` to write/obtain the types of
96
+ // nodes within the function.
97
+ //
98
+ // The types of top-level items, which never contain unbound type
99
+ // variables, are stored directly into the `tcx` tables.
100
+ //
101
+ // n.b.: A type variable is not the same thing as a type parameter. A
102
+ // type variable is rather an "instance" of a type parameter: that is,
103
+ // given a generic function `fn foo<T>(t: T)`: while checking the
104
+ // function `foo`, the type `ty_param(0)` refers to the type `T`, which
105
+ // is treated in abstract. When `foo()` is called, however, `T` will be
106
+ // substituted for a fresh type variable `ty_var(N)`. This variable will
107
+ // eventually be resolved to some concrete type (which might itself be
108
+ // type parameter).
85
109
node_types : smallintmap:: smallintmap < ty:: t > ,
86
110
node_type_substs : hashmap < ast:: node_id , [ ty:: t ] > ,
111
+
87
112
ccx : @crate_ctxt } ;
88
113
89
114
// Determines whether the given node ID is a use of the def of
0 commit comments