Skip to content

Commit 2a16a12

Browse files
More docs
1 parent 8917894 commit 2a16a12

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

compiler/rustc_middle/src/traits/mod.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,21 @@ pub enum ObligationCauseCode<'tcx> {
234234
/// This is the trait reference from the given projection.
235235
ProjectionWf(ty::ProjectionTy<'tcx>),
236236

237-
/// In an impl of trait `X` for type `Y`, type `Y` must
238-
/// also implement all supertraits of `X`.
237+
/// Must satisfy all of the where-clause predicates of the
238+
/// given item.
239239
ItemObligation(DefId),
240240

241-
ExprItemObligation(DefId, rustc_hir::HirId, usize),
242-
243-
/// Like `ItemObligation`, but with extra detail on the source of the obligation.
241+
/// Like `ItemObligation`, but carries the span of the
242+
/// predicate when it can be identified.
244243
BindingObligation(DefId, Span),
245244

245+
/// Like `ItemObligation`, but carries the `HirId` of the
246+
/// expression that caused the obligation, and the `usize`
247+
/// indicates exactly which predicate it is in the list of
248+
/// instantiated predicates.
249+
ExprItemObligation(DefId, rustc_hir::HirId, usize),
250+
251+
/// Combines `ExprItemObligation` and `BindingObligation`.
246252
ExprBindingObligation(DefId, Span, rustc_hir::HirId, usize),
247253

248254
/// A type like `&'a T` is WF only if `T: 'a`.

compiler/rustc_middle/src/ty/generics.rs

+4
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ pub struct Generics {
122122
}
123123

124124
impl<'tcx> Generics {
125+
/// Looks through the generics and all parents to find the index of the
126+
/// given param def-id. This is in comparison to the `param_def_id_to_index`
127+
/// struct member, which only stores information about this item's own
128+
/// generics.
125129
pub fn param_def_id_to_index(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<u32> {
126130
if let Some(idx) = self.param_def_id_to_index.get(&def_id) {
127131
Some(*idx)

compiler/rustc_span/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ impl Span {
664664
Some(self)
665665
}
666666

667+
/// Like `find_ancestor_inside`, but specifically for when spans might not
668+
/// overlaps. Take care when using this, and prefer `find_ancestor_inside`
669+
/// when you know that the spans are nested (modulo macro expansion).
667670
pub fn find_ancestor_in_same_ctxt(mut self, other: Span) -> Option<Span> {
668671
while !Span::eq_ctxt(self, other) {
669672
self = self.parent_callsite()?;

0 commit comments

Comments
 (0)