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
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 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.
Trait Implementations
sourceimpl<'tcx> Clone for ObligationCause<'tcx>
impl<'tcx> Clone for ObligationCause<'tcx>
sourcefn clone(&self) -> ObligationCause<'tcx>
fn clone(&self) -> ObligationCause<'tcx>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl<'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
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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<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,
sourceimpl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
sourceimpl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
impl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
default fn from_cycle_error(tcx: CTX) -> T
impl<'a, T> Captures<'a> for Twhere
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