rust/src/librustc_typeck
Manish Goregaokar 2dba874d57
Rollup merge of #48452 - varkor:unpacked-kind, r=eddyb
Introduce UnpackedKind

This adds an `UnpackedKind` type as a typesafe counterpart to `Kind`. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker will be able to catch more potential issues.

r? @eddyb
cc @yodaldevoid
2018-02-24 15:52:15 -08:00
..
check Rollup merge of #48452 - varkor:unpacked-kind, r=eddyb 2018-02-24 15:52:15 -08:00
coherence change overlapping_impls to take a tcx and create the infcx 2018-01-30 14:00:24 -05:00
outlives
variance Introduce UnpackedKind 2018-02-23 01:13:54 +00:00
astconv.rs Introduce UnpackedKind 2018-02-23 01:13:54 +00:00
Cargo.toml
check_unused.rs
collect.rs add Self: Trait<..> inside the param_env of a default impl 2018-02-15 15:31:05 +00:00
constrained_type_params.rs
diagnostics.rs inform type annotations 2018-02-14 11:06:08 +08:00
impl_wf_check.rs
lib.rs stage0 cfg cleanup 2018-02-20 08:52:33 -07:00
namespace.rs
README.md
structured_errors.rs Rename -Z explain to -Z teach 2018-01-23 11:34:57 -08:00

NB: This crate is part of the Rust compiler. For an overview of the compiler as a whole, see the README.md file found in librustc.

The rustc_typeck crate contains the source for "type collection" and "type checking", as well as a few other bits of related functionality. (It draws heavily on the type inferencing and trait solving code found in librustc.)

Type collection

Type "collection" is the process of converting the types found in the HIR (hir::Ty), which represent the syntactic things that the user wrote, into the internal representation used by the compiler (Ty<'tcx>) -- we also do similar conversions for where-clauses and other bits of the function signature.

To try and get a sense for the difference, consider this function:

struct Foo { }
fn foo(x: Foo, y: self::Foo) { .. }
//        ^^^     ^^^^^^^^^

Those two parameters x and y each have the same type: but they will have distinct hir::Ty nodes. Those nodes will have different spans, and of course they encode the path somewhat differently. But once they are "collected" into Ty<'tcx> nodes, they will be represented by the exact same internal type.

Collection is defined as a bundle of queries (e.g., type_of) for computing information about the various functions, traits, and other items in the crate being compiled. Note that each of these queries is concerned with interprocedural things -- for example, for a function definition, collection will figure out the type and signature of the function, but it will not visit the body of the function in any way, nor examine type annotations on local variables (that's the job of type checking).

For more details, see the collect module.

Type checking

TODO