Module rustc::infer::at
[−]
[src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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
At |
[ Experimental ]
|
Trace |
[ Experimental ]
|
Traits
ToTrace |
[ Experimental ]
|