Crate ra_ap_hir_ty
source ·Expand description
The type system. We currently use this to infer types for completion, hover information and various assists.
Re-exports
pub use autoderef::autoderef;pub use method_resolution::check_orphan_rules;pub use traits::TraitEnvironment;
Modules
- In certain situations, rust automatically inserts derefs as necessary: for example, field accesses
foo.barstill work whenfoois actually a reference to a type with the fieldbar. This is an approximation of the logic in rustc (which lives in rustc_hir_analysis/check/autoderef.rs). - Constant evaluation details
- The home of
HirDatabase, which is the Salsa database containing all the type inference-related queries. - Type inference-based diagnostics.
- The
HirDisplaytrait, which serves two purposes: Turning various bits from HIR back into source code, and just displaying them for debugging/testing purposes. - Functions to detect special lang items
- Compute the binary representation of a type
- This module is concerned with finding methods that a given type provides. For details about how this works in rustc, see the method lookup page in the rustc guide and the corresponding code mostly in rustc_hir_analysis/check/method/probe.rs.
- MIR definitions and implementation
- A few helper functions for dealing with primitives.
- Trait solving using Chalk.
Macros
Structs
- Represents coercing a value to a different type of value.
- The id for an Abstract Data Type (i.e. structs, unions and enums).
- Identifies a particular bound variable within a binder. Variables are identified by the combination of a
DebruijnIndex, which identifies the binder, and an index within that binder. - A function signature as seen by type inference: Several parameter types and one return type.
- References the binder at the given depth. The index is a de Bruijn index, so it counts back through the in-scope binders, with 0 being the innermost binder. This is used in impls and the like. For example, if we had a rule like
for<T> { (T: Clone) :- (T: Copy) }, thenTwould be represented as aBoundVar(0)(as theforis the innermost binder). - A wrapper for the substs on a Fn.
- The result of type inference: A mapping from expressions and patterns to types.
- An overloaded autoderef step, representing a
Deref(Mut)::deref(_mut)call, with the signature&'a T -> &'a Uor&'a mut T -> &'a mut U. The target type isUin both cases, with the region and mutability being those shared by both the receiver and the returned reference. - This is a builder for
Tyor anything that needs aSubstitution.
Enums
- Binding modes inferred for patterns. https://doc.rust-lang.org/reference/patterns.html#binding-modes
- A concrete constant value
- A constant can have reference to other things. Memory map job is holding the necessary bits of memory of the const eval session to keep the constant meaningful.
- Whether a type is mutable or not.
- Whether a function is safe or not.
- Types of scalar values.
- Represents some extra knowledge we may have about the type variable.
Traits
- The
Casttrait is used to make annoying upcasts between logically equivalent types that imply wrappers. For example, one could convert aDomainGoalinto aGoalby doing:
Functions
- Returns an iterator over the whole super trait hierarchy (including the trait itself).
- Returns unique placeholders for types and consts contained in
value. - Return an index of a parameter in the generic type parameter list by it’s id.
- ‘Canonicalizes’ the
tby replacing any errors with new variables. Also ensures there are no unbound variables or inference variables anywhere in thet.
Type Aliases
- Represents generic parameters and an item bound by them. When the item has parent, the binders also contain the generic parameters for its parent. See chalk’s documentation for details.
- A polymorphic function signature.
- Interned list of generic arguments for an item. When an item has parent, the
Substitutionfor it contains generic arguments for both its parent and itself. See chalk’s documentation for details.