Module rustc_trait_selection::infer::at

source ·
Expand description

A nice interface for working with the infcx. The basic idea is to do infcx.at(cause, param_env), which sets the “cause” of the operation as well as the surrounding parameter environment. Then you can do something like .sub(a, b) or .eq(a, b) to create a subtype or equality relationship respectively. The first argument is always the “expected” output from the POV of diagnostics.

Examples:

    infcx.at(cause, param_env).sub(a, b)
    // requires that `a <: b`, with `a` considered the "expected" type

    infcx.at(cause, param_env).sup(a, b)
    // requires that `b <: a`, with `a` considered the "expected" type

    infcx.at(cause, param_env).eq(a, b)
    // requires that `a == b`, with `a` considered the "expected" type

For finer-grained control, you can also do use trace:

    infcx.at(...).trace(a, b).sub(&c, &d)

This will set a and b as the “root” values for error-reporting, but actually operate on c and d. This is sometimes useful when the types of c and d are not traceable things. (That system should probably be refactored.)

Structs§

Enums§

Traits§