More docs
This commit is contained in:
parent
8917894fda
commit
2a16a127a0
3 changed files with 18 additions and 5 deletions
|
@ -234,15 +234,21 @@ pub enum ObligationCauseCode<'tcx> {
|
||||||
/// This is the trait reference from the given projection.
|
/// This is the trait reference from the given projection.
|
||||||
ProjectionWf(ty::ProjectionTy<'tcx>),
|
ProjectionWf(ty::ProjectionTy<'tcx>),
|
||||||
|
|
||||||
/// In an impl of trait `X` for type `Y`, type `Y` must
|
/// Must satisfy all of the where-clause predicates of the
|
||||||
/// also implement all supertraits of `X`.
|
/// given item.
|
||||||
ItemObligation(DefId),
|
ItemObligation(DefId),
|
||||||
|
|
||||||
ExprItemObligation(DefId, rustc_hir::HirId, usize),
|
/// Like `ItemObligation`, but carries the span of the
|
||||||
|
/// predicate when it can be identified.
|
||||||
/// Like `ItemObligation`, but with extra detail on the source of the obligation.
|
|
||||||
BindingObligation(DefId, Span),
|
BindingObligation(DefId, Span),
|
||||||
|
|
||||||
|
/// Like `ItemObligation`, but carries the `HirId` of the
|
||||||
|
/// expression that caused the obligation, and the `usize`
|
||||||
|
/// indicates exactly which predicate it is in the list of
|
||||||
|
/// instantiated predicates.
|
||||||
|
ExprItemObligation(DefId, rustc_hir::HirId, usize),
|
||||||
|
|
||||||
|
/// Combines `ExprItemObligation` and `BindingObligation`.
|
||||||
ExprBindingObligation(DefId, Span, rustc_hir::HirId, usize),
|
ExprBindingObligation(DefId, Span, rustc_hir::HirId, usize),
|
||||||
|
|
||||||
/// A type like `&'a T` is WF only if `T: 'a`.
|
/// A type like `&'a T` is WF only if `T: 'a`.
|
||||||
|
|
|
@ -122,6 +122,10 @@ pub struct Generics {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Generics {
|
impl<'tcx> Generics {
|
||||||
|
/// Looks through the generics and all parents to find the index of the
|
||||||
|
/// given param def-id. This is in comparison to the `param_def_id_to_index`
|
||||||
|
/// struct member, which only stores information about this item's own
|
||||||
|
/// generics.
|
||||||
pub fn param_def_id_to_index(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<u32> {
|
pub fn param_def_id_to_index(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<u32> {
|
||||||
if let Some(idx) = self.param_def_id_to_index.get(&def_id) {
|
if let Some(idx) = self.param_def_id_to_index.get(&def_id) {
|
||||||
Some(*idx)
|
Some(*idx)
|
||||||
|
|
|
@ -664,6 +664,9 @@ impl Span {
|
||||||
Some(self)
|
Some(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Like `find_ancestor_inside`, but specifically for when spans might not
|
||||||
|
/// overlaps. Take care when using this, and prefer `find_ancestor_inside`
|
||||||
|
/// when you know that the spans are nested (modulo macro expansion).
|
||||||
pub fn find_ancestor_in_same_ctxt(mut self, other: Span) -> Option<Span> {
|
pub fn find_ancestor_in_same_ctxt(mut self, other: Span) -> Option<Span> {
|
||||||
while !Span::eq_ctxt(self, other) {
|
while !Span::eq_ctxt(self, other) {
|
||||||
self = self.parent_callsite()?;
|
self = self.parent_callsite()?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue