rustc_trait_selection

Module traits

source
Expand description

Trait Resolution. See the rustc dev guide for more information on how this works.

Re-exports§

Modules§

  • Support code for rustdoc and external tools. You really don’t want to be using this unless you need to.
  • coherence 🔒
    See Rustc Dev Guide chapters on trait-resolution and trait-specialization for more info on how this works.
  • Checking that constant values used in types can be successfully evaluated.
  • “Dyn-compatibility” refers to the ability for a trait to be converted to a trait object. In general, traits may only be converted to a trait object if certain criteria are met.
  • engine 🔒
  • fulfill 🔒
  • Miscellaneous type-system utilities that are too small to deserve their own modules.
  • Deeply normalize types using the old trait solver.
  • Code for projecting associated types out of trait references.
  • Experimental types for the trait query interface. The methods defined in this module are all based on canonicalization, which makes a canonical query by replacing unbound inference variables and regions, so that results can be reused more broadly. The providers for the queries defined here can be found in rustc_traits.
  • select 🔒
    Candidate selection. See the rustc dev guide for more information on how this works.
  • specialize 🔒
    Logic and data structures related to impl specialization, explained in greater detail below.
  • util 🔒

Structs§

  • The fulfillment context is used to drive trait resolution. It consists of a list of obligations that must be (eventually) satisfied. The job is to track which are satisfied, which yielded errors, and which are still pending. At any point, users can call select_where_possible, and the fulfillment context will try to do selection, retaining only those obligations that remain ambiguous. This may be helpful in pushing type inference along. Once all type inference constraints have been generated, the method select_all_or_error can be used to report any remaining ambiguous cases as errors.
  • Identifies a particular impl in the source, along with a set of generic parameters from the impl’s type/lifetime parameters. The nested vector corresponds to the nested obligations attached to the impl’s type parameters.
  • An Obligation represents some trait reference (e.g., i32: Eq) for which the “impl_source” must be found. The process of finding an “impl_source” is called “resolving” the Obligation. This process consists of either identifying an impl (e.g., impl Eq for i32) that satisfies the obligation, or else finding a bound that is in scope. The eventual result is usually a Selection (defined below).
  • The reason why we incurred this obligation; used for error reporting.
  • Used if you want to have pleasant experience when dealing with obligations outside of hir or mir typeck.
  • Information pertinent to an overlapping impl error.
  • The inverse of BoundVarReplacer: replaces placeholders with the bound vars from which they came.
  • The projection cache. Unlike the standard caches, this can include infcx-dependent type variables, therefore we have to roll the cache back each time we roll a snapshot back, to avoid assumptions on yet-unresolved inference variables. Types with placeholder regions also have to be removed when the respective snapshot ends.
  • “Trait alias expansion” is the process of expanding a sequence of trait references into another sequence by transitively following all trait aliases. e.g. If you have bounds like Foo + Send, a trait alias trait Foo = Bar + Sync;, and another trait alias trait Bar = Read + Write, then the bounds would expand to Read + Write + Sync + Send. Expansion is done via a DFS (depth-first search), and the visited field is used to avoid cycles.
  • Stores information about the expansion of a trait via a path of zero or more trait aliases.

Enums§

Traits§

Functions§

Type Aliases§