Skip to content

Commit 0876a83

Browse files
committed
document closure_base_def_id
1 parent 4fa3eff commit 0876a83

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustc/ty/util.rs

+7
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
624624
self.def_key(def_id).disambiguated_data.data == DefPathData::ClosureExpr
625625
}
626626

627+
/// Given the `DefId` of a fn or closure, returns the `DefId` of
628+
/// the innermost fn item that the closure is contained within.
629+
/// This is a significant def-id because, when we do
630+
/// type-checking, we type-check this fn item and all of its
631+
/// (transitive) closures together. Therefore, when we fetch the
632+
/// `typeck_tables_of` the closure, for example, we really wind up
633+
/// fetching the `typeck_tables_of` the enclosing fn item.
627634
pub fn closure_base_def_id(self, def_id: DefId) -> DefId {
628635
let mut def_id = def_id;
629636
while self.is_closure(def_id) {

0 commit comments

Comments
 (0)