Struct rustc_middle::traits::ObligationCause
source · [−]pub struct ObligationCause<'tcx> {
pub span: Span,
pub body_id: HirId,
code: Option<Lrc<ObligationCauseCode<'tcx>>>,
}Expand description
The reason why we incurred this obligation; used for error reporting.
Non-misc ObligationCauseCodes 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: Spanbody_id: HirIdThe 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: Option<Lrc<ObligationCauseCode<'tcx>>>None for MISC_OBLIGATION_CAUSE_CODE (a common case, occurs ~60% of
the time). Some otherwise.
Implementations
sourceimpl<'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 make_mut_code(&mut self) -> &mut ObligationCauseCode<'tcx>
pub fn span(&self, tcx: TyCtxt<'tcx>) -> Span
pub fn code(&self) -> &ObligationCauseCode<'tcx>
pub fn clone_code(&self) -> Lrc<ObligationCauseCode<'tcx>>
Trait Implementations
sourceimpl<'tcx> Clone for ObligationCause<'tcx>
impl<'tcx> Clone for ObligationCause<'tcx>
sourcefn clone(&self) -> ObligationCause<'tcx>
fn clone(&self) -> ObligationCause<'tcx>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<'tcx> Debug for ObligationCause<'tcx>
impl<'tcx> Debug for ObligationCause<'tcx>
sourceimpl Hash for ObligationCause<'_>
impl Hash for ObligationCause<'_>
sourceimpl<'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>>
sourceimpl<'tcx> PartialEq<ObligationCause<'tcx>> for ObligationCause<'tcx>
impl<'tcx> PartialEq<ObligationCause<'tcx>> for ObligationCause<'tcx>
sourcefn eq(&self, other: &ObligationCause<'tcx>) -> bool
fn eq(&self, other: &ObligationCause<'tcx>) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &ObligationCause<'tcx>) -> bool
fn ne(&self, other: &ObligationCause<'tcx>) -> bool
This method tests for !=.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<'a, T> Captures<'a> for T where
T: ?Sized,
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