rust/src/librustc_typeck
bors f62f774035 Auto merge of #47167 - ivanbakel:builtin_indexing, r=nikomatsakis
Fix built-in indexing not being used where index type wasn't "obviously" usize

Fixes #33903
Fixes #46095

This PR was made possible thanks to the generous help of @eddyb

Following the example of binary operators, builtin checking for indexing has been moved from the typecheck stage to a writeback stage, after type constraints have been resolved.
2018-01-10 12:29:05 +00:00
..
check Auto merge of #47167 - ivanbakel:builtin_indexing, r=nikomatsakis 2018-01-10 12:29:05 +00:00
coherence rustc::ty: Rename struct_variant to non_enum_variant 2018-01-08 00:28:05 +01:00
outlives add a test case 2017-10-16 14:26:17 -04:00
variance add a new RegionKind variant: ReClosureBound 2017-12-15 10:27:52 -05:00
astconv.rs Auto merge of #46754 - cramertj:refactor-arg-impl, r=nikomatsakis 2017-12-21 08:04:57 +00:00
Cargo.toml Try to fix a perf regression by updating log 2018-01-07 16:54:05 +01:00
check_unused.rs rustc: Filter out bogus extern crate warnings 2017-11-30 08:03:04 -08:00
collect.rs Add GenericParam, refactor Generics in ast, hir, rustdoc 2017-12-21 13:38:10 +01:00
constrained_type_params.rs bring TyCtxt into scope 2017-09-14 21:26:06 -04:00
diagnostics.rs Do not use casting for suggestion to add type to numeric literal 2018-01-04 15:28:21 -08:00
impl_wf_check.rs Add GenericParam, refactor Generics in ast, hir, rustdoc 2017-12-21 13:38:10 +01:00
lib.rs rustc: Don't use relative paths for extended errors 2018-01-04 07:21:22 -08:00
namespace.rs Check namespaces when resolving associated items in typeck 2017-10-15 11:58:32 +01:00
README.md Fix typos 2017-11-04 18:23:54 +09: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