Module rustc::middle::typeck::astconv[src]
Conversion from AST representation of types to the ty.rs
representation. The main routine here is ast_ty_to_ty(): each use
is parameterized by an instance of AstConv and a RegionScope.
The parameterization of ast_ty_to_ty() is because it behaves
somewhat differently during the collect and check phases,
particularly with respect to looking up the types of top-level
items. In the collect phase, the crate context is used as the
AstConv instance; in this phase, the get_item_ty() function
triggers a recursive call to ty_of_item() (note that
ast_ty_to_ty() will detect recursive types and report an error).
In the check phase, when the FnCtxt is used as the AstConv,
get_item_ty() just looks up the item type in tcx.tcache.
The RegionScope trait controls what happens when the user does
not specify a region in some location where a region is required
(e.g., if the user writes &Foo as a type rather than &'a Foo).
See the rscope module for more details.
Unlike the AstConv trait, the region scope can change as we descend
the type. This is to accommodate the fact that (a) fn types are binding
scopes and (b) the default region may change. To understand case (a),
consider something like:
type foo = { x: &a.int, y: |&a.int| }
The type of x is an error because there is no region a in scope.
In the type of y, however, region a is considered a bound region
as it does not already appear in scope.
Case (b) says that if you have a type:
type foo<'a> = ...;
type bar = fn(&foo, &a.foo)
The fully expanded version of type bar is:
type bar = fn(&'foo &, &a.foo<'a>)
Note that the self region for the foo defaulted to & in the first
case but &a in the second. Basically, defaults that appear inside
an rptr (&r.T) use the region r that appears in the rptr.
Statics
pub static NO_REGIONS: uint = 1 |
|
pub static NO_TPS: uint = 2 |
Traits
| AstConv |
Functions
| ast_path_to_trait_ref | |
| ast_path_to_ty | |
| ast_region_to_region | |
| ast_ty_to_builtin_ty | Converts the given AST type to a built-in type. A "built-in type" is, at
present, either a core numeric type, a string, or |
| ast_ty_to_prim_ty | |
| ast_ty_to_ty | |
| opt_ast_region_to_region | |
| trait_ref_for_unboxed_function | |
| ty_of_arg | |
| ty_of_bare_fn | |
| ty_of_closure | |
| ty_of_method |