mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 01:23:26 +00:00
More docs
This commit is contained in:
parent
8917894fda
commit
2a16a127a0
@ -234,15 +234,21 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
/// This is the trait reference from the given projection.
|
||||
ProjectionWf(ty::ProjectionTy<'tcx>),
|
||||
|
||||
/// In an impl of trait `X` for type `Y`, type `Y` must
|
||||
/// also implement all supertraits of `X`.
|
||||
/// Must satisfy all of the where-clause predicates of the
|
||||
/// given item.
|
||||
ItemObligation(DefId),
|
||||
|
||||
ExprItemObligation(DefId, rustc_hir::HirId, usize),
|
||||
|
||||
/// Like `ItemObligation`, but with extra detail on the source of the obligation.
|
||||
/// Like `ItemObligation`, but carries the span of the
|
||||
/// predicate when it can be identified.
|
||||
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),
|
||||
|
||||
/// A type like `&'a T` is WF only if `T: 'a`.
|
||||
|
@ -122,6 +122,10 @@ pub struct 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> {
|
||||
if let Some(idx) = self.param_def_id_to_index.get(&def_id) {
|
||||
Some(*idx)
|
||||
|
@ -664,6 +664,9 @@ impl Span {
|
||||
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> {
|
||||
while !Span::eq_ctxt(self, other) {
|
||||
self = self.parent_callsite()?;
|
||||
|
Loading…
Reference in New Issue
Block a user