Struct rustc_typeck::traits::SelectionContext [−][src]
pub struct SelectionContext<'cx, 'tcx> {
infcx: &'cx InferCtxt<'cx, 'tcx>,
freshener: TypeFreshener<'cx, 'tcx>,
intercrate: bool,
intercrate_ambiguity_causes: Option<Vec<IntercrateAmbiguityCause, Global>>,
allow_negative_impls: bool,
is_in_const_context: bool,
query_mode: TraitQueryMode,
}Fields
infcx: &'cx InferCtxt<'cx, 'tcx>freshener: TypeFreshener<'cx, 'tcx>Freshener used specifically for entries on the obligation stack. This ensures that all entries on the stack at one time will have the same set of placeholder entries, which is important for checking for trait bounds that recursively require themselves.
intercrate: boolIf true, indicates that the evaluation should be conservative
and consider the possibility of types outside this crate.
This comes up primarily when resolving ambiguity. Imagine
there is some trait reference $0: Bar where $0 is an
inference variable. If intercrate is true, then we can never
say for sure that this reference is not implemented, even if
there are no impls at all for Bar, because $0 could be
bound to some type that in a downstream crate that implements
Bar. This is the suitable mode for coherence. Elsewhere,
though, we set this to false, because we are only interested
in types that the user could actually have written — in
other words, we consider $0: Bar to be unimplemented if
there is no type that the user could actually name that
would satisfy it. This avoids crippling inference, basically.
intercrate_ambiguity_causes: Option<Vec<IntercrateAmbiguityCause, Global>>allow_negative_impls: boolControls whether or not to filter out negative impls when selecting. This is used in librustdoc to distinguish between the lack of an impl and a negative impl
is_in_const_context: boolAre we in a const context that needs ~const bounds to be const?
query_mode: TraitQueryModeThe mode that trait queries run in, which informs our error handling policy. In essence, canonicalized queries need their errors propagated rather than immediately reported because we do not have accurate spans.
Auto Trait Implementations
impl<'cx, 'tcx> !RefUnwindSafe for SelectionContext<'cx, 'tcx>
impl<'cx, 'tcx> !Send for SelectionContext<'cx, 'tcx>
impl<'cx, 'tcx> !Sync for SelectionContext<'cx, 'tcx>
impl<'cx, 'tcx> Unpin for SelectionContext<'cx, 'tcx> where
'tcx: 'cx,
impl<'cx, 'tcx> !UnwindSafe for SelectionContext<'cx, 'tcx>
Blanket Implementations
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 128 bytes