Struct rustc_middle::traits::ObligationCause
source · pub struct ObligationCause<'tcx> {
pub span: Span,
pub body_id: HirId,
code: InternedObligationCauseCode<'tcx>,
}
Expand description
The reason why we incurred this obligation; used for error reporting.
Non-misc ObligationCauseCode
s are stored on the heap. This gives the
best trade-off between keeping the type small (which makes copies cheaper)
while not doing too many heap allocations.
We do not want to intern this as there are a lot of obligation causes which only live for a short period of time.
Fields§
§span: Span
§body_id: HirId
The ID of the fn body that triggered this obligation. This is
used for region obligations to determine the precise
environment in which the region obligation should be evaluated
(in particular, closures can add new assumptions). See the
field region_obligations
of the FulfillmentContext
for more
information.
code: InternedObligationCauseCode<'tcx>
Implementations§
source§impl<'tcx> ObligationCause<'tcx>
impl<'tcx> ObligationCause<'tcx>
pub fn new(
span: Span,
body_id: HirId,
code: ObligationCauseCode<'tcx>
) -> ObligationCause<'tcx>
pub fn misc(span: Span, body_id: HirId) -> ObligationCause<'tcx>
pub fn dummy() -> ObligationCause<'tcx>
pub fn dummy_with_span(span: Span) -> ObligationCause<'tcx>
pub fn span(&self) -> Span
pub fn code(&self) -> &ObligationCauseCode<'tcx>
pub fn map_code(
&mut self,
f: impl FnOnce(InternedObligationCauseCode<'tcx>) -> ObligationCauseCode<'tcx>
)
sourcepub fn derived_cause(
self,
parent_trait_pred: PolyTraitPredicate<'tcx>,
variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>
) -> ObligationCause<'tcx>
pub fn derived_cause(
self,
parent_trait_pred: PolyTraitPredicate<'tcx>,
variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>
) -> ObligationCause<'tcx>
Creates a cause for obligations that are derived from
obligation
by a recursive search (e.g., for a builtin
bound, or eventually a auto trait Foo
). If obligation
is itself a derived obligation, this is just a clone, but
otherwise we create a “derived obligation” cause so as to
keep track of the original root obligation for error
reporting.
pub fn to_constraint_category(&self) -> ConstraintCategory<'tcx>
Trait Implementations§
source§impl<'tcx> Clone for ObligationCause<'tcx>
impl<'tcx> Clone for ObligationCause<'tcx>
source§fn clone(&self) -> ObligationCause<'tcx>
fn clone(&self) -> ObligationCause<'tcx>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'tcx> Debug for ObligationCause<'tcx>
impl<'tcx> Debug for ObligationCause<'tcx>
source§impl Hash for ObligationCause<'_>
impl Hash for ObligationCause<'_>
source§impl<'tcx, '__lifted> Lift<'__lifted> for ObligationCause<'tcx>
impl<'tcx, '__lifted> Lift<'__lifted> for ObligationCause<'tcx>
type Lifted = ObligationCause<'__lifted>
fn lift_to_tcx(
self,
__tcx: TyCtxt<'__lifted>
) -> Option<ObligationCause<'__lifted>>
source§impl<'tcx> PartialEq<ObligationCause<'tcx>> for ObligationCause<'tcx>
impl<'tcx> PartialEq<ObligationCause<'tcx>> for ObligationCause<'tcx>
source§fn eq(&self, other: &ObligationCause<'tcx>) -> bool
fn eq(&self, other: &ObligationCause<'tcx>) -> bool
impl<'tcx> Eq for ObligationCause<'tcx>
impl<'tcx> StructuralEq for ObligationCause<'tcx>
impl<'tcx> StructuralPartialEq for ObligationCause<'tcx>
Auto Trait Implementations§
impl<'tcx> !RefUnwindSafe for ObligationCause<'tcx>
impl<'tcx> !Send for ObligationCause<'tcx>
impl<'tcx> !Sync for ObligationCause<'tcx>
impl<'tcx> Unpin for ObligationCause<'tcx>
impl<'tcx> !UnwindSafe for ObligationCause<'tcx>
Blanket Implementations§
source§impl<T, R> InternIteratorElement<T, R> for T
impl<T, R> InternIteratorElement<T, R> for T
type Output = R
fn intern_with<I, F>(iter: I, f: F) -> <T as InternIteratorElement<T, R>>::Outputwhere
I: Iterator<Item = T>,
F: FnOnce(&[T]) -> R,
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<'tcx, T> ToPredicate<'tcx, T> for T
impl<'tcx, T> ToPredicate<'tcx, T> for T
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error(tcx: Tcx, _: &[QueryInfo]) -> T
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: 24 bytes