Expand description

“Collection” is the process of determining the type and other external details of each item in Rust. Collection is specifically concerned with inter-procedural 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).

Collecting is ultimately defined by a bundle of queries that inquire after various facts about the items in the crate (e.g., type_of, generics_of, predicates_of, etc). See the provide function for the full set.

At present, however, we do run collection across all items in the crate as a kind of pass. This should eventually be factored away.

Modules

type_of 🔒

Structs

Context specific to some particular item. This is what implements AstConv.

Functions

adt_def 🔒
Computes the set of target features used in a function for the purposes of inline assembly.
Checks the function annotated with #[target_feature] is not a safe trait method implementation, reporting an error if it is.
Returns the early-bound lifetimes declared in this generics listing. For anything other than fns/methods, this is just all the lifetimes that are declared. For fns or methods, we have to screen out those that do not appear in any where-clauses etc using resolve_lifetime::early_bound_lifetimes.
fn_sig 🔒
Returns a list of user-specified type predicates for the definition with ID def_id. N.B., this does not include any implied/inferred constraints.
Synthesize a new lifetime name that doesn’t clash with any of the lifetimes already present.
Whether ty is a type with _ placeholders that can be inferred. Used in diagnostics only to use inference to provide suggestions for the appropriate type if possible.
If there are any placeholder types (_), emit an error explaining that this is not allowed and suggest adding type parameters in the appropriate place, taking into consideration any and all already existing generic type parameters to avoid suggesting a name that is already in use.
Returns a list of type predicates for the definition with ID def_id, including inferred lifetime constraints. This includes all predicates returned by explicit_predicates_of, plus inferred constraints concerning which regions outlive other regions.
Converts a specific GenericBound from the AST into a set of predicates that apply to the self type. A vector is returned because this can be anywhere from zero predicates (T: ?Sized adds no predicates) to one (T: Foo) to many (T: Bar<X = i32> adds T: Bar and <T as Bar>::X == i32).
Returns a list of all type predicates (explicit and implicit) for the definition with ID def_id. This includes all predicates returned by predicates_defined_on, plus Self: Trait predicates for traits.
Checks if the provided DefId is a method in a trait impl for a trait which has track_caller applied to the method prototype.
Ensures that the super-predicates of the trait with a DefId of trait_def_id are converted and stored. This also ensures that the transitive super-predicates are converted.
Ensures that the super-predicates of the trait with a DefId of trait_def_id are converted and stored. This also ensures that the transitive super-predicates are converted.
trait_def 🔒
Returns the predicates defined on item_def_id of the form X: Foo where X is the type parameter def_id.