Crate rustc_typeckUnstable[stability] [-] [+] [src]

typeck.rs, an introduction

The type checker is responsible for:

  1. Determining the type of each expression
  2. Resolving methods and traits
  3. Guaranteeing that most type rules are met ("most?", you say, "why most?" Well, dear reader, read on)

The main entry point is check_crate(). Type checking operates in several major phases:

  1. The collect phase first passes over all items and determines their type, without examining their "innards".

  2. Variance inference then runs to compute the variance of each parameter

  3. Coherence checks for overlapping or orphaned impls

  4. Finally, the check phase then checks function bodies and so forth. Within the check phase, we check each function body one at a time (bodies of function expressions are checked as part of the containing function). Inference is used to supply types wherever they are unknown. The actual checking of a function itself has several phases (check, regionck, writeback), as discussed in the documentation for the check module.

The type checker is defined into various submodules which are documented independently:

Note

This API is completely unstable and subject to change.

Modules

diagnostics
lint

Lints, aka compiler warnings.

metadata
middle
session
util

Structs

CrateCtxt
TypeAndSubsts

Functions

check_crate