1 NB: This crate is part of the Rust compiler. For an overview of the
2 compiler as a whole, see
3 [the README.md file found in `librustc`](../librustc/README.md).
5 The `rustc_typeck` crate contains the source for "type collection" and
6 "type checking", as well as a few other bits of related functionality.
7 (It draws heavily on the [type inferencing][infer] and
8 [trait solving][traits] code found in librustc.)
10 [infer]: ../librustc/infer/README.md
11 [traits]: ../librustc/traits/README.md
15 Type "collection" is the process of convering the types found in the
16 HIR (`hir::Ty`), which represent the syntactic things that the user
17 wrote, into the **internal representation** used by the compiler
18 (`Ty<'tcx>`) -- we also do similar conversions for where-clauses and
19 other bits of the function signature.
21 To try and get a sense for the difference, consider this function:
25 fn foo(x: Foo, y: self::Foo) { .. }
29 Those two parameters `x` and `y` each have the same type: but they
30 will have distinct `hir::Ty` nodes. Those nodes will have different
31 spans, and of course they encode the path somewhat differently. But
32 once they are "collected" into `Ty<'tcx>` nodes, they will be
33 represented by the exact same internal type.
35 Collection is defined as a bundle of queries (e.g., `type_of`) for
36 computing information about the various functions, traits, and other
37 items in the crate being compiled. Note that each of these queries is
38 concerned with *interprocedural* things -- for example, for a function
39 definition, collection will figure out the type and signature of the
40 function, but it will not visit the *body* of the function in any way,
41 nor examine type annotations on local variables (that's the job of
44 For more details, see the `collect` module.