Skip to content

Commit 2e90bb4

Browse files
committed
---
yaml --- r: 12229 b: refs/heads/master c: 35a3fa0 h: refs/heads/master i: 12227: a44297d v: v3
1 parent 5dcc1c9 commit 2e90bb4

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2b45da8a339d1e2935d250cfae63b44a3b16688f
2+
refs/heads/master: 35a3fa099930e2bb87bd4e4a911039be8fc19e2d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/ty.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,18 @@ type ctxt =
194194
sess: session::session,
195195
def_map: resolve::def_map,
196196
region_map: @middle::region::region_map,
197+
198+
// Stores the types for various nodes in the AST. Note that this table
199+
// is not guaranteed to be populated until after typeck. See
200+
// typeck::fn_ctxt for details.
197201
node_types: node_type_table,
202+
203+
// Stores the type parameters which were substituted to obtain the type
204+
// of this node. This only applies to nodes that refer to entities
205+
// parameterized by type parameters, such as generic fns, types, or
206+
// other items.
198207
node_type_substs: hashmap<node_id, [t]>,
208+
199209
items: ast_map::map,
200210
freevars: freevars::freevar_map,
201211
tcache: type_cache,

trunk/src/rustc/middle/typeck.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,33 @@ type fn_ctxt =
8282
locals: hashmap<ast::node_id, int>,
8383
next_var_id: @mut int,
8484
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).
85109
node_types: smallintmap::smallintmap<ty::t>,
86110
node_type_substs: hashmap<ast::node_id, [ty::t]>,
111+
87112
ccx: @crate_ctxt};
88113

89114
// Determines whether the given node ID is a use of the def of

0 commit comments

Comments
 (0)